#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 strtol(char *, int /*<<< orphan*/, int);
int main(int argc, char *argv[]) {
  int a;
  int b;
  int r;
  printf("+ Demo Project version : %d.%d\n", 0, 1);
  printf("+ Project Home         : https://gitlab.com/gdb/demoi\n");
  a = strtol(argv[1], 0, 10);
  b = strtol(argv[2], 0, 10);
  if (argv[3][0] == '+') {
    r = a + b;
  } else if (argv[3][0] == '-') {
    r = a - b;
  } else if (argv[3][0] == '*') {
    r = a * b;
  } else if (argv[3][0] == '/') {
    r = a / b;
  }
  printf("%d\n", r);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xec3(%rip),%rdi
xor    %esi,%esi
mov    $0x1,%edx
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xece(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
movsbl (%rax),%eax
cmp    $0x2b,%eax
jne    11a9 <main+0x89>
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    121b <main+0xfb>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    11cb <main+0xab>
mov    -0x14(%rbp),%eax
sub    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1216 <main+0xf6>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
movsbl (%rax),%eax
cmp    $0x2a,%eax
jne    11ee <main+0xce>
mov    -0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1211 <main+0xf1>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    120c <main+0xec>
mov    -0x14(%rbp),%eax
cltd
idivl  -0x18(%rbp)
mov    %eax,-0x1c(%rbp)
jmp    1211 <main+0xf1>
jmp    1216 <main+0xf6>
jmp    121b <main+0xfb>
mov    -0x1c(%rbp),%esi
lea    0xdf7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
lea    0xedb(%rip),%rdi
xor    %esi,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xee6(%rip),%rdi
call   1030 <puts@plt>
mov    0x8(%rbx),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,%ebp
mov    0x10(%rbx),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,%esi
mov    0x18(%rbx),%rax
mov    (%rax),%al
add    $0xd6,%al
movzbl %al,%eax
lea    0xe73(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
imul   %ebp,%esi
jmp    11ac <main+0x7c>
mov    %ebp,%eax
cltd
idiv   %esi
mov    %eax,%esi
jmp    11ac <main+0x7c>
add    %ebp,%esi
jmp    11ac <main+0x7c>
sub    %esi,%ebp
mov    %ebp,%esi
lea    0xe81(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"+ Demo Project version : %d.%d\0A\00"
@.str.1 = [55 x i8] c"+ Project Home : https://gitlab.com/gdb/demoi\0A\00"
@.str.2 = [4 x i8] c"%d\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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 0, i32 1)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0))
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i32 @strtol(i8* %13, i32 0, i32 10)
store i32 %14, i32* %6
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 2
%17 = load i8*, i8** %16
%18 = call i32 @strtol(i8* %17, i32 0, i32 10)
store i32 %18, i32* %7
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 3
%21 = load i8*, i8** %20
%22 = getelementptr inbounds i8, i8* %21, i64 0
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 43
br i1 %25, label %26, label %30
26: ; preds = %2
%27 = load i32, i32* %6
%28 = load i32, i32* %7
%29 = add nsw i32 %27, %28
store i32 %29, i32* %8
br label %69
30: ; preds = %2
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 3
%33 = load i8*, i8** %32
%34 = getelementptr inbounds i8, i8* %33, i64 0
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 45
br i1 %37, label %38, label %42
38: ; preds = %30
%39 = load i32, i32* %6
%40 = load i32, i32* %7
%41 = sub nsw i32 %39, %40
store i32 %41, i32* %8
br label %68
42: ; preds = %30
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 3
%45 = load i8*, i8** %44
%46 = getelementptr inbounds i8, i8* %45, i64 0
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = icmp eq i32 %48, 42
br i1 %49, label %50, label %54
50: ; preds = %42
%51 = load i32, i32* %6
%52 = load i32, i32* %7
%53 = mul nsw i32 %51, %52
store i32 %53, i32* %8
br label %67
54: ; preds = %42
%55 = load i8**, i8*** %5
%56 = getelementptr inbounds i8*, i8** %55, i64 3
%57 = load i8*, i8** %56
%58 = getelementptr inbounds i8, i8* %57, i64 0
%59 = load i8, i8* %58
%60 = sext i8 %59 to i32
%61 = icmp eq i32 %60, 47
br i1 %61, label %62, label %66
62: ; preds = %54
%63 = load i32, i32* %6
%64 = load i32, i32* %7
%65 = sdiv i32 %63, %64
store i32 %65, i32* %8
br label %66
66: ; preds = %62, %54
br label %67
67: ; preds = %66, %50
br label %68
68: ; preds = %67, %38
br label %69
69: ; preds = %68, %26
%70 = load i32, i32* %8
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %70)
ret i32 0
}

LLVM IR (-O2):
@.str = [32 x i8] c"+ Demo Project version : %d.%d\0A\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@str = [54 x i8] c"+ Project Home : https://gitlab.com/gdb/demoi\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 0, i32 1)
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str, i64 0, i64 0))
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @strtol(i8* %6, i32 0, i32 10)
%8 = getelementptr inbounds i8*, i8** %1, i64 2
%9 = load i8*, i8** %8
%10 = tail call i32 @strtol(i8* %9, i32 0, i32 10)
%11 = getelementptr inbounds i8*, i8** %1, i64 3
%12 = load i8*, i8** %11
%13 = load i8, i8* %12
switch i8 %13, label %22 [
i8 43, label %14
i8 45, label %16
i8 42, label %18
i8 47, label %20
]
14: ; preds = %2
%15 = add nsw i32 %10, %7
br label %23
16: ; preds = %2
%17 = sub nsw i32 %7, %10
br label %23
18: ; preds = %2
%19 = mul nsw i32 %10, %7
br label %23
20: ; preds = %2
%21 = sdiv i32 %7, %10
br label %23
22: ; preds = %2
unreachable
23: ; preds = %16, %20, %18, %14
%24 = phi i32 [ %15, %14 ], [ %17, %16 ], [ %19, %18 ], [ %21, %20 ]
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %24)
ret i32 0
}