#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, ...);
int main(void) {
  int i, j, k;
  i = 5;
  j = 3;
  printf("4.1 (a):  %d %d \n", i / j, i % j);
  i = 2;
  j = 3;
  printf("4.1 (b):  %d \n", (i + 10) % j);
  i = 7;
  j = 8;
  k = 9;
  printf("4.1 (c):  %d \n", (i + 10) % k / j);
  i = 1;
  j = 2;
  k = 3;
  printf("4.1 (d):  %d \n", (i + 5) % (j + 2) / k);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x5,-0x8(%rbp)
movl   $0x3,-0xc(%rbp)
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %eax,%esi
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x2,-0x8(%rbp)
movl   $0x3,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0xa,%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,%esi
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x7,-0x8(%rbp)
movl   $0x8,-0xc(%rbp)
movl   $0x9,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0xa,%eax
cltd
idivl  -0x10(%rbp)
mov    %edx,%eax
cltd
idivl  -0xc(%rbp)
mov    %eax,%esi
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x8(%rbp)
movl   $0x2,-0xc(%rbp)
movl   $0x3,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x5,%eax
mov    -0xc(%rbp),%ecx
add    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
cltd
idivl  -0x10(%rbp)
mov    %eax,%esi
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xee8(%rip),%rdi
mov    $0x1,%esi
mov    $0x2,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee2(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee1(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xedd(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [18 x i8] c"4.1 (a): %d %d \0A\00"
@.str.1 = [15 x i8] c"4.1 (b): %d \0A\00"
@.str.2 = [15 x i8] c"4.1 (c): %d \0A\00"
@.str.3 = [15 x i8] c"4.1 (d): %d \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 5, i32* %2
store i32 3, i32* %3
%5 = load i32, i32* %2
%6 = load i32, i32* %3
%7 = sdiv i32 %5, %6
%8 = load i32, i32* %2
%9 = load i32, i32* %3
%10 = srem i32 %8, %9
%11 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %10)
store i32 2, i32* %2
store i32 3, i32* %3
%12 = load i32, i32* %2
%13 = add nsw i32 %12, 10
%14 = load i32, i32* %3
%15 = srem i32 %13, %14
%16 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %15)
store i32 7, i32* %2
store i32 8, i32* %3
store i32 9, i32* %4
%17 = load i32, i32* %2
%18 = add nsw i32 %17, 10
%19 = load i32, i32* %4
%20 = srem i32 %18, %19
%21 = load i32, i32* %3
%22 = sdiv i32 %20, %21
%23 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %22)
store i32 1, i32* %2
store i32 2, i32* %3
store i32 3, i32* %4
%24 = load i32, i32* %2
%25 = add nsw i32 %24, 5
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 2
%28 = srem i32 %25, %27
%29 = load i32, i32* %4
%30 = sdiv i32 %28, %29
%31 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %30)
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"4.1 (a): %d %d \0A\00"
@.str.1 = [15 x i8] c"4.1 (b): %d \0A\00"
@.str.2 = [15 x i8] c"4.1 (c): %d \0A\00"
@.str.3 = [15 x i8] c"4.1 (d): %d \0A\00"
define i32 @main() {
%1 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 1, i32 2)
%2 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 0)
%3 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 1)
%4 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 0)
ret i32 0
}