#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;
  int b = 5;
  int c = 10;
  int 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);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x19,-0x8(%rbp)
movl   $0x5,-0xc(%rbp)
movl   $0xa,-0x10(%rbp)
movl   $0x7,-0x14(%rbp)
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,%esi
lea    0xeb5(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    %edx,%esi
lea    0xead(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x14(%rbp)
mov    %edx,%esi
lea    0xeb1(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x14(%rbp)
mov    %eax,%esi
imul   -0x14(%rbp),%esi
mov    -0x8(%rbp),%eax
cltd
idivl  -0x14(%rbp)
add    %edx,%esi
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%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
%5 = alloca i32
store i32 0, i32* %1
store i32 25, i32* %2
store i32 5, i32* %3
store i32 10, i32* %4
store i32 7, i32* %5
%6 = load i32, i32* %2
%7 = load i32, i32* %3
%8 = srem i32 %6, %7
%9 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = load i32, i32* %2
%11 = load i32, i32* %4
%12 = srem i32 %10, %11
%13 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = load i32, i32* %2
%15 = load i32, i32* %5
%16 = srem i32 %14, %15
%17 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = load i32, i32* %2
%19 = load i32, i32* %5
%20 = sdiv i32 %18, %19
%21 = load i32, i32* %5
%22 = mul nsw i32 %20, %21
%23 = load i32, i32* %2
%24 = load i32, i32* %5
%25 = srem i32 %23, %24
%26 = add nsw i32 %22, %25
%27 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %26)
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
}