#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 /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  if (argc != 4) {
    printf("expression invalide\n");
    return 1;
  }
  int value1 = atoi(argv[1]);
  int value2 = atoi(argv[3]);
  char operateur = *argv[2];
  if (operateur == '+') {
    int result = value1 + value2;
    printf("%d", result);
  } else if (operateur == '-') {
    int result = value1 - value2;
    printf("%d", result);
  } else if (operateur == '/') {
    if (value2 == 0) {
      printf("expression invalide\n");
      return 1;
    }
    int result = value1 / value2;
    printf("%d", result);
  } else if (operateur == '*') {
    int result = value1 * value2;
    printf("%d", result);
  } else if (operateur == '%') {
    int result = value1 % value2;
    printf("%d", result);
  } else {
    printf("expression invalide\n");
    return 1;
  }
  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)
cmpl   $0x4,-0x8(%rbp)
je     115a <main+0x3a>
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12bf <main+0x19f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    (%rax),%al
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
cmp    $0x2b,%eax
jne    11b3 <main+0x93>
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%esi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12b8 <main+0x198>
movsbl -0x19(%rbp),%eax
cmp    $0x2d,%eax
jne    11df <main+0xbf>
mov    -0x14(%rbp),%eax
sub    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%esi
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12b3 <main+0x193>
movsbl -0x19(%rbp),%eax
cmp    $0x2f,%eax
jne    1230 <main+0x110>
cmpl   $0x0,-0x18(%rbp)
jne    1210 <main+0xf0>
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12bf <main+0x19f>
mov    -0x14(%rbp),%eax
cltd
idivl  -0x18(%rbp)
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%esi
lea    0xdf1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12ae <main+0x18e>
movsbl -0x19(%rbp),%eax
cmp    $0x2a,%eax
jne    125d <main+0x13d>
mov    -0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%esi
lea    0xdc4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12a9 <main+0x189>
movsbl -0x19(%rbp),%eax
cmp    $0x25,%eax
jne    128a <main+0x16a>
mov    -0x14(%rbp),%eax
cltd
idivl  -0x18(%rbp)
mov    %edx,-0x30(%rbp)
mov    -0x30(%rbp),%esi
lea    0xd97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12a4 <main+0x184>
lea    0xd6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12bf <main+0x19f>
jmp    12a9 <main+0x189>
jmp    12ae <main+0x18e>
jmp    12b3 <main+0x193>
jmp    12b8 <main+0x198>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x4,%edi
jne    11c4 <main+0x94>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
mov    %eax,%ebp
mov    0x18(%rbx),%rdi
call   1050 <atoi@plt>
mov    %eax,%esi
mov    0x10(%rbx),%rax
mov    (%rax),%al
add    $0xdb,%al
cmp    $0xa,%al
ja     11c4 <main+0x94>
movzbl %al,%eax
lea    0xe95(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    %ebp,%eax
cltd
idiv   %esi
lea    0xeac(%rip),%rdi
xor    %ebx,%ebx
mov    %edx,%esi
jmp    11bb <main+0x8b>
imul   %ebp,%esi
jmp    118d <main+0x5d>
add    %ebp,%esi
lea    0xe98(%rip),%rdi
xor    %ebx,%ebx
jmp    11bb <main+0x8b>
sub    %esi,%ebp
lea    0xe8b(%rip),%rdi
xor    %ebx,%ebx
mov    %ebp,%esi
jmp    11bb <main+0x8b>
test   %esi,%esi
je     11c4 <main+0x94>
mov    %ebp,%eax
cltd
idiv   %esi
lea    0xe75(%rip),%rdi
xor    %ebx,%ebx
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11d5 <main+0xa5>
lea    0xe64(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"expression invalide\0A\00"
@.str.1 = [3 x i8] c"%d\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 i8
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 4
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %92
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @atoi(i8* %21)
store i32 %22, i32* %6
%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* %7
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 2
%29 = load i8*, i8** %28
%30 = load i8, i8* %29
store i8 %30, i8* %8
%31 = load i8, i8* %8
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 43
br i1 %33, label %34, label %40
34: ; preds = %18
%35 = load i32, i32* %6
%36 = load i32, i32* %7
%37 = add nsw i32 %35, %36
store i32 %37, i32* %9
%38 = load i32, i32* %9
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %38)
br label %91
40: ; preds = %18
%41 = load i8, i8* %8
%42 = sext i8 %41 to i32
%43 = icmp eq i32 %42, 45
br i1 %43, label %44, label %50
44: ; preds = %40
%45 = load i32, i32* %6
%46 = load i32, i32* %7
%47 = sub nsw i32 %45, %46
store i32 %47, i32* %10
%48 = load i32, i32* %10
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %48)
br label %90
50: ; preds = %40
%51 = load i8, i8* %8
%52 = sext i8 %51 to i32
%53 = icmp eq i32 %52, 47
br i1 %53, label %54, label %65
54: ; preds = %50
%55 = load i32, i32* %7
%56 = icmp eq i32 %55, 0
br i1 %56, label %57, label %59
57: ; preds = %54
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %92
59: ; preds = %54
%60 = load i32, i32* %6
%61 = load i32, i32* %7
%62 = sdiv i32 %60, %61
store i32 %62, i32* %11
%63 = load i32, i32* %11
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %63)
br label %89
65: ; preds = %50
%66 = load i8, i8* %8
%67 = sext i8 %66 to i32
%68 = icmp eq i32 %67, 42
br i1 %68, label %69, label %75
69: ; preds = %65
%70 = load i32, i32* %6
%71 = load i32, i32* %7
%72 = mul nsw i32 %70, %71
store i32 %72, i32* %12
%73 = load i32, i32* %12
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %73)
br label %88
75: ; preds = %65
%76 = load i8, i8* %8
%77 = sext i8 %76 to i32
%78 = icmp eq i32 %77, 37
br i1 %78, label %79, label %85
79: ; preds = %75
%80 = load i32, i32* %6
%81 = load i32, i32* %7
%82 = srem i32 %80, %81
store i32 %82, i32* %13
%83 = load i32, i32* %13
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %83)
br label %87
85: ; preds = %75
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %92
87: ; preds = %79
br label %88
88: ; preds = %87, %69
br label %89
89: ; preds = %88, %59
br label %90
90: ; preds = %89, %44
br label %91
91: ; preds = %90, %34
store i32 0, i32* %3
br label %92
92: ; preds = %91, %85, %57, %16
%93 = load i32, i32* %3
ret i32 %93
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@str.3 = [20 x i8] c"expression invalide\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.3, i64 0, i64 0))
br label %37
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 3
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = load i8, i8* %14
switch i8 %15, label %35 [
i8 43, label %16
i8 45, label %19
i8 47, label %22
i8 42, label %29
i8 37, label %32
]
16: ; preds = %6
%17 = add nsw i32 %12, %9
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %17)
br label %37
19: ; preds = %6
%20 = sub nsw i32 %9, %12
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %20)
br label %37
22: ; preds = %6
%23 = icmp eq i32 %12, 0
br i1 %23, label %24, label %26
24: ; preds = %22
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.3, i64 0, i64 0))
br label %37
26: ; preds = %22
%27 = sdiv i32 %9, %12
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %27)
br label %37
29: ; preds = %6
%30 = mul nsw i32 %12, %9
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %30)
br label %37
32: ; preds = %6
%33 = srem i32 %9, %12
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %33)
br label %37
35: ; preds = %6
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.3, i64 0, i64 0))
br label %37
37: ; preds = %24, %35, %19, %29, %32, %26, %16, %4
%38 = phi i32 [ 1, %4 ], [ 1, %24 ], [ 1, %35 ], [ 0, %19 ], [ 0, %29 ], [ 0, %32 ], [ 0, %26 ], [ 0, %16 ]
ret i32 %38
}