#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 lib_add(int const, int const);
int lib_div(int const, int const);
int lib_mul(int const, int const);
int lib_sub(int const, int const);
int /*<<< orphan*/ printf(char *, int const, int const, int);
int main(void) {
  const int a = 4;
  const int b = 2;
  printf("%d + %d = %d\n", a, b, lib_add(a, b));
  printf("%d - %d = %d\n", a, b, lib_sub(a, b));
  printf("%d * %d = %d\n", a, b, lib_mul(a, b));
  printf("%d / %d = %d\n", a, b, lib_div(a, b));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x4,-0x8(%rbp)
movl   $0x2,-0xc(%rbp)
mov    $0x4,%edi
mov    $0x2,%esi
call   1060 <lib_add@plt>
mov    %eax,%ecx
lea    0xe7b(%rip),%rdi
mov    $0x4,%esi
mov    $0x2,%edx
call   1050 <printf@plt>
mov    $0x4,%edi
mov    $0x2,%esi
call   1030 <lib_sub@plt>
mov    %eax,%ecx
lea    0xe62(%rip),%rdi
mov    $0x4,%esi
mov    $0x2,%edx
call   1050 <printf@plt>
mov    $0x4,%edi
mov    $0x2,%esi
call   1040 <lib_mul@plt>
mov    %eax,%ecx
lea    0xe49(%rip),%rdi
mov    $0x4,%esi
mov    $0x2,%edx
call   1050 <printf@plt>
mov    $0x4,%edi
mov    $0x2,%esi
call   1070 <lib_div@plt>
mov    %eax,%ecx
lea    0xe30(%rip),%rdi
mov    $0x4,%esi
mov    $0x2,%edx
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x4,%edi
mov    $0x2,%esi
call   1060 <lib_add@plt>
lea    0xe99(%rip),%rdi
mov    $0x4,%esi
mov    $0x2,%edx
mov    %eax,%ecx
call   1050 <printf@plt>
mov    $0x4,%edi
mov    $0x2,%esi
call   1030 <lib_sub@plt>
lea    0xe80(%rip),%rdi
mov    $0x4,%esi
mov    $0x2,%edx
mov    %eax,%ecx
call   1050 <printf@plt>
mov    $0x4,%edi
mov    $0x2,%esi
call   1040 <lib_mul@plt>
lea    0xe67(%rip),%rdi
mov    $0x4,%esi
mov    $0x2,%edx
mov    %eax,%ecx
call   1050 <printf@plt>
mov    $0x4,%edi
mov    $0x2,%esi
call   1070 <lib_div@plt>
lea    0xe4e(%rip),%rdi
mov    $0x4,%esi
mov    $0x2,%edx
mov    %eax,%ecx
call   1050 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 4, i32* %2
store i32 2, i32* %3
%4 = call i32 @lib_add(i32 4, i32 2)
%5 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 4, i32 2, i32 %4)
%6 = call i32 @lib_sub(i32 4, i32 2)
%7 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 4, i32 2, i32 %6)
%8 = call i32 @lib_mul(i32 4, i32 2)
%9 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 4, i32 2, i32 %8)
%10 = call i32 @lib_div(i32 4, i32 2)
%11 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 4, i32 2, i32 %10)
ret i32 0
}

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"
define i32 @main() {
%1 = tail call i32 @lib_add(i32 4, i32 2)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 4, i32 2, i32 %1)
%3 = tail call i32 @lib_sub(i32 4, i32 2)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 4, i32 2, i32 %3)
%5 = tail call i32 @lib_mul(i32 4, i32 2)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 4, i32 2, i32 %5)
%7 = tail call i32 @lib_div(i32 4, i32 2)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 4, i32 2, i32 %7)
ret i32 0
}