#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 a = 25, b = 5, c = 10, d = 7;
  printf("a %% b = %i\n", a % b);
  printf("a %% c = %i\n", a % c);
  printf("a %% d = %i\n", a % d);
  printf("a / d * d + a %% d = %i\n", a / d * d + a % d);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x19,-0x4(%rbp)
movl   $0x5,-0x8(%rbp)
movl   $0xa,-0xc(%rbp)
movl   $0x7,-0x10(%rbp)
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %edx,%esi
lea    0xebc(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,%esi
lea    0xeb4(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    %edx,%esi
lea    0xeb8(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    %eax,%esi
imul   -0x10(%rbp),%esi
mov    -0x4(%rbp),%eax
cltd
idivl  -0x10(%rbp)
add    %edx,%esi
lea    0xe8a(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xee8(%rip),%rdi
xor    %esi,%esi
call   1030 <printf@plt>
lea    0xee7(%rip),%rdi
mov    $0x5,%esi
call   1030 <printf@plt>
lea    0xeef(%rip),%rdi
mov    $0x4,%esi
call   1030 <printf@plt>
lea    0xed2(%rip),%rdi
mov    $0x19,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

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