#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, int);
void expr_arithmetic_test() {
  int a = 6, b = 2, c, d, e, f, g;
  c = a + b;
  d = a - b;
  e = a * b;
  f = a / b;
  g = a % b;
  printf("%d + %d = %d\n", a, b, c);
  printf("%d - %d = %d\n", a, b, d);
  printf("%d * %d = %d\n", a, b, e);
  printf("%d / %d = %d\n", a, b, f);
  printf("%d %% %d = %d\n", a, b, g);
}


x86 assembly (clang, -O0):
<expr_arithmetic_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x6,-0x4(%rbp)
movl   $0x2,-0x8(%rbp)
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
imul   -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe93(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xe8c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xe85(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x1c(%rbp),%ecx
lea    0xe7e(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<expr_arithmetic_test>:
push   %rax
lea    0xee8(%rip),%rdi
mov    $0x6,%esi
mov    $0x2,%edx
mov    $0x8,%ecx
call   1030 <printf@plt>
lea    0xedb(%rip),%rdi
mov    $0x6,%esi
mov    $0x2,%edx
mov    $0x4,%ecx
call   1030 <printf@plt>
lea    0xece(%rip),%rdi
mov    $0x6,%esi
mov    $0x2,%edx
mov    $0xc,%ecx
call   1030 <printf@plt>
lea    0xec1(%rip),%rdi
mov    $0x6,%esi
mov    $0x2,%edx
mov    $0x3,%ecx
call   1030 <printf@plt>
lea    0xeb4(%rip),%rdi
mov    $0x6,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
pop    %rax
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"%d + %d = %d\0A\00"
@.str.1 = [14 x i8] c"%d - %d = %d\0A\00"
@.str.2 = [14 x i8] c"%d * %d = %d\0A\00"
@.str.3 = [14 x i8] c"%d / %d = %d\0A\00"
@.str.4 = [15 x i8] c"%d %% %d = %d\0A\00"
define void @expr_arithmetic_test() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 6, i32* %1
store i32 2, i32* %2
%8 = load i32, i32* %1
%9 = load i32, i32* %2
%10 = add nsw i32 %8, %9
store i32 %10, i32* %3
%11 = load i32, i32* %1
%12 = load i32, i32* %2
%13 = sub nsw i32 %11, %12
store i32 %13, i32* %4
%14 = load i32, i32* %1
%15 = load i32, i32* %2
%16 = mul nsw i32 %14, %15
store i32 %16, i32* %5
%17 = load i32, i32* %1
%18 = load i32, i32* %2
%19 = sdiv i32 %17, %18
store i32 %19, i32* %6
%20 = load i32, i32* %1
%21 = load i32, i32* %2
%22 = srem i32 %20, %21
store i32 %22, i32* %7
%23 = load i32, i32* %1
%24 = load i32, i32* %2
%25 = load i32, i32* %3
%26 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %23, i32 %24, i32 %25)
%27 = load i32, i32* %1
%28 = load i32, i32* %2
%29 = load i32, i32* %4
%30 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %27, i32 %28, i32 %29)
%31 = load i32, i32* %1
%32 = load i32, i32* %2
%33 = load i32, i32* %5
%34 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %31, i32 %32, i32 %33)
%35 = load i32, i32* %1
%36 = load i32, i32* %2
%37 = load i32, i32* %6
%38 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %35, i32 %36, i32 %37)
%39 = load i32, i32* %1
%40 = load i32, i32* %2
%41 = load i32, i32* %7
%42 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %39, i32 %40, i32 %41)
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"%d + %d = %d\0A\00"
@.str.1 = [14 x i8] c"%d - %d = %d\0A\00"
@.str.2 = [14 x i8] c"%d * %d = %d\0A\00"
@.str.3 = [14 x i8] c"%d / %d = %d\0A\00"
@.str.4 = [15 x i8] c"%d %% %d = %d\0A\00"
define void @expr_arithmetic_test() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 6, i32 2, i32 8)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 6, i32 2, i32 4)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 6, i32 2, i32 12)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 6, i32 2, i32 3)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 6, i32 2, i32 0)
ret void
}