#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 atoi(char *);
int delen(int, int);
int optellen(int, int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  int i = 0;
  int term1;
  int term2;
  int operator;
  if (argc == 1) {
    printf(
        "1 is optellen, 2 is vermenigvuldigen, 3 is aftrekken, 4 is delen\n");
    return 0;
  }
  term1 = atoi(argv[1]);
  term2 = atoi(argv[2]);
  operator= atoi(argv[3]);
  if (operator== 1)
    printf("de som van %i en %i = %i\n	", term1, term2,
           optellen(term1, term2));
  if (operator== 2)
    printf("Het product van %i en %i = %i\n", term1, term2, term1 * term2);
  if (operator== 3)
    printf("Het verschil van %i en %i = %i\n", term1, term2, term1 - term2);
  if (operator== 4) {
    printf("Het quotient van %i en %i = %i\n", term1, term2,
           delen(term1, term2));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1181 <main+0x41>
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    126f <main+0x12f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x1,-0x20(%rbp)
jne    11e8 <main+0xa8>
mov    -0x18(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1060 <optellen@plt>
mov    -0x28(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    %eax,%ecx
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x2,-0x20(%rbp)
jne    120d <main+0xcd>
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x3,-0x20(%rbp)
jne    1231 <main+0xf1>
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%ecx
sub    -0x1c(%rbp),%ecx
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x4,-0x20(%rbp)
jne    1268 <main+0x128>
mov    -0x18(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1040 <delen@plt>
mov    -0x30(%rbp),%esi
mov    -0x2c(%rbp),%edx
mov    %eax,%ecx
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
cmp    $0x1,%edi
jne    116a <main+0x1a>
lea    0xf2a(%rip),%rdi
call   1030 <puts@plt>
jmp    11f9 <main+0xa9>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1060 <atoi@plt>
mov    %eax,%r14d
mov    0x10(%rbx),%rdi
call   1060 <atoi@plt>
mov    %eax,%ebp
mov    0x18(%rbx),%rdi
call   1060 <atoi@plt>
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     11f9 <main+0xa9>
lea    0xe64(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    %r14d,%edi
mov    %ebp,%esi
call   1070 <optellen@plt>
lea    0xe5a(%rip),%rdi
jmp    11eb <main+0x9b>
mov    %ebp,%ecx
imul   %r14d,%ecx
lea    0xe66(%rip),%rdi
jmp    11d3 <main+0x83>
mov    %r14d,%ecx
sub    %ebp,%ecx
lea    0xe77(%rip),%rdi
mov    %r14d,%esi
mov    %ebp,%edx
jmp    11f2 <main+0xa2>
mov    %r14d,%edi
mov    %ebp,%esi
call   1050 <delen@plt>
lea    0xe7f(%rip),%rdi
mov    %r14d,%esi
mov    %ebp,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [66 x i8] c"1 is optellen, 2 is vermenigvuldigen, 3 is aftrekken, 4 is delen\0A\00"
@.str.1 = [27 x i8] c"de som van %i en %i = %i\0A\09\00"
@.str.2 = [31 x i8] c"Het product van %i en %i = %i\0A\00"
@.str.3 = [32 x i8] c"Het verschil van %i en %i = %i\0A\00"
@.str.4 = [32 x i8] c"Het quotient van %i en %i = %i\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %67
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @atoi(i8* %17)
store i32 %18, i32* %7
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 2
%21 = load i8*, i8** %20
%22 = call i32 @atoi(i8* %21)
store i32 %22, i32* %8
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 3
%25 = load i8*, i8** %24
%26 = call i32 @atoi(i8* %25)
store i32 %26, i32* %9
%27 = load i32, i32* %9
%28 = icmp eq i32 %27, 1
br i1 %28, label %29, label %36
29: ; preds = %14
%30 = load i32, i32* %7
%31 = load i32, i32* %8
%32 = load i32, i32* %7
%33 = load i32, i32* %8
%34 = call i32 @optellen(i32 %32, i32 %33)
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %30, i32 %31, i32 %34)
br label %36
36: ; preds = %29, %14
%37 = load i32, i32* %9
%38 = icmp eq i32 %37, 2
br i1 %38, label %39, label %46
39: ; preds = %36
%40 = load i32, i32* %7
%41 = load i32, i32* %8
%42 = load i32, i32* %7
%43 = load i32, i32* %8
%44 = mul nsw i32 %42, %43
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %40, i32 %41, i32 %44)
br label %46
46: ; preds = %39, %36
%47 = load i32, i32* %9
%48 = icmp eq i32 %47, 3
br i1 %48, label %49, label %56
49: ; preds = %46
%50 = load i32, i32* %7
%51 = load i32, i32* %8
%52 = load i32, i32* %7
%53 = load i32, i32* %8
%54 = sub nsw i32 %52, %53
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %50, i32 %51, i32 %54)
br label %56
56: ; preds = %49, %46
%57 = load i32, i32* %9
%58 = icmp eq i32 %57, 4
br i1 %58, label %59, label %66
59: ; preds = %56
%60 = load i32, i32* %7
%61 = load i32, i32* %8
%62 = load i32, i32* %7
%63 = load i32, i32* %8
%64 = call i32 @delen(i32 %62, i32 %63)
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i32 %60, i32 %61, i32 %64)
br label %66
66: ; preds = %59, %56
store i32 0, i32* %3
br label %67
67: ; preds = %66, %12
%68 = load i32, i32* %3
ret i32 %68
}

LLVM IR (-O2):
@.str.1 = [27 x i8] c"de som van %i en %i = %i\0A\09\00"
@.str.2 = [31 x i8] c"Het product van %i en %i = %i\0A\00"
@.str.3 = [32 x i8] c"Het verschil van %i en %i = %i\0A\00"
@.str.4 = [32 x i8] c"Het quotient van %i en %i = %i\0A\00"
@str = [65 x i8] c"1 is optellen, 2 is vermenigvuldigen, 3 is aftrekken, 4 is delen\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @str, i64 0, i64 0))
br label %28
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @atoi(i8* %8)
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
%13 = getelementptr inbounds i8*, i8** %1, i64 3
%14 = load i8*, i8** %13
%15 = tail call i32 @atoi(i8* %14)
switch i32 %15, label %28 [
i32 1, label %16
i32 2, label %19
i32 3, label %22
i32 4, label %25
]
16: ; preds = %6
%17 = tail call i32 @optellen(i32 %9, i32 %12)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %9, i32 %12, i32 %17)
br label %28
19: ; preds = %6
%20 = mul nsw i32 %12, %9
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %9, i32 %12, i32 %20)
br label %28
22: ; preds = %6
%23 = sub nsw i32 %9, %12
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %9, i32 %12, i32 %23)
br label %28
25: ; preds = %6
%26 = tail call i32 @delen(i32 %9, i32 %12)
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i32 %9, i32 %12, i32 %26)
br label %28
28: ; preds = %22, %19, %16, %25, %6, %4
ret i32 0
}