#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 do_op(int, int, char);
int ft_atoi(char *);
int /*<<< orphan*/ ft_putchar(char);
int /*<<< orphan*/ ft_putnbr(int);
int /*<<< orphan*/ ft_putstr(char *);
int main(int argc, char **argv) {
  int a;
  int b;
  int result;
  char op;
  if (argc == 4) {
    a = ft_atoi(argv[1]);
    b = ft_atoi(argv[3]);
    op = argv[2][0];
    result = 0;
    if (op == '/' && b == 0)
      ft_putstr("Stop : division by zero");
    else if (op == '%' && b == 0)
      ft_putstr("Stop : modulo by zero");
    else {
      if (argv[2][1] == '\0')
        result = do_op(a, b, op);
      ft_putnbr(result);
    }
    ft_putchar('\n');
  }
  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)
cmpl   $0x4,-0x8(%rbp)
jne    1232 <main+0xe2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <ft_atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1070 <ft_atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    (%rax),%al
mov    %al,-0x1d(%rbp)
movl   $0x0,-0x1c(%rbp)
movsbl -0x1d(%rbp),%eax
cmp    $0x2f,%eax
jne    11cc <main+0x7c>
cmpl   $0x0,-0x18(%rbp)
jne    11cc <main+0x7c>
lea    0xe3e(%rip),%rdi
call   1050 <ft_putstr@plt>
jmp    1228 <main+0xd8>
movsbl -0x1d(%rbp),%eax
cmp    $0x25,%eax
jne    11f4 <main+0xa4>
cmpl   $0x0,-0x18(%rbp)
jne    11f4 <main+0xa4>
lea    0xe2e(%rip),%rdi
call   1050 <ft_putstr@plt>
jmp    1223 <main+0xd3>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
jne    121b <main+0xcb>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
movsbl -0x1d(%rbp),%edx
call   1060 <do_op@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   1040 <ft_putnbr@plt>
jmp    1228 <main+0xd8>
mov    $0xa,%edi
call   1030 <ft_putchar@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
cmp    $0x4,%edi
jne    11ce <main+0x7e>
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1070 <ft_atoi@plt>
mov    %eax,%ebp
mov    0x18(%rbx),%rdi
call   1070 <ft_atoi@plt>
mov    0x10(%rbx),%rdx
mov    (%rdx),%cl
cmp    $0x2f,%cl
jne    118c <main+0x3c>
test   %eax,%eax
jne    118c <main+0x3c>
lea    0xe7b(%rip),%rdi
call   1050 <ft_putstr@plt>
jmp    11be <main+0x6e>
cmp    $0x25,%cl
jne    11a3 <main+0x53>
test   %eax,%eax
jne    11a3 <main+0x53>
lea    0xe7c(%rip),%rdi
call   1050 <ft_putstr@plt>
jmp    11be <main+0x6e>
xor    %edi,%edi
cmpb   $0x0,0x1(%rdx)
jne    11b9 <main+0x69>
movsbl %cl,%edx
mov    %ebp,%edi
mov    %eax,%esi
call   1060 <do_op@plt>
mov    %eax,%edi
call   1040 <ft_putnbr@plt>
mov    $0xa,%edi
call   1030 <ft_putchar@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
xor    %eax,%eax
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Stop : division by zero\00"
@.str.1 = [22 x i8] c"Stop : modulo by zero\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 i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 4
br i1 %11, label %12, label %62
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @ft_atoi(i8* %15)
store i32 %16, i32* %6
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 3
%19 = load i8*, i8** %18
%20 = call i32 @ft_atoi(i8* %19)
store i32 %20, i32* %7
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 2
%23 = load i8*, i8** %22
%24 = getelementptr inbounds i8, i8* %23, i64 0
%25 = load i8, i8* %24
store i8 %25, i8* %9
store i32 0, i32* %8
%26 = load i8, i8* %9
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 47
br i1 %28, label %29, label %34
29: ; preds = %12
%30 = load i32, i32* %7
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %29
%33 = call i32 @ft_putstr(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %60
34: ; preds = %29, %12
%35 = load i8, i8* %9
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 37
br i1 %37, label %38, label %43
38: ; preds = %34
%39 = load i32, i32* %7
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %38
%42 = call i32 @ft_putstr(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %59
43: ; preds = %38, %34
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 2
%46 = load i8*, i8** %45
%47 = getelementptr inbounds i8, i8* %46, i64 1
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp eq i32 %49, 0
br i1 %50, label %51, label %56
51: ; preds = %43
%52 = load i32, i32* %6
%53 = load i32, i32* %7
%54 = load i8, i8* %9
%55 = call i32 @do_op(i32 %52, i32 %53, i8 signext %54)
store i32 %55, i32* %8
br label %56
56: ; preds = %51, %43
%57 = load i32, i32* %8
%58 = call i32 @ft_putnbr(i32 %57)
br label %59
59: ; preds = %56, %41
br label %60
60: ; preds = %59, %32
%61 = call i32 @ft_putchar(i8 signext 10)
br label %62
62: ; preds = %60, %2
ret i32 0
}

LLVM IR (-O2):
@.str = [24 x i8] c"Stop : division by zero\00"
@.str.1 = [22 x i8] c"Stop : modulo by zero\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %4, label %35
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @ft_atoi(i8* %6)
%8 = getelementptr inbounds i8*, i8** %1, i64 3
%9 = load i8*, i8** %8
%10 = tail call i32 @ft_atoi(i8* %9)
%11 = getelementptr inbounds i8*, i8** %1, i64 2
%12 = load i8*, i8** %11
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 47
%15 = icmp eq i32 %10, 0
%16 = select i1 %14, i1 %15, i1 false
br i1 %16, label %17, label %19
17: ; preds = %4
%18 = tail call i32 @ft_putstr(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %33
19: ; preds = %4
%20 = icmp eq i8 %13, 37
%21 = select i1 %20, i1 %15, i1 false
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = tail call i32 @ft_putstr(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %33
24: ; preds = %19
%25 = getelementptr inbounds i8, i8* %12, i64 1
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %24
%29 = tail call i32 @do_op(i32 %7, i32 %10, i8 signext %13)
br label %30
30: ; preds = %28, %24
%31 = phi i32 [ %29, %28 ], [ 0, %24 ]
%32 = tail call i32 @ft_putnbr(i32 %31)
br label %33
33: ; preds = %22, %30, %17
%34 = tail call i32 @ft_putchar(i8 signext 10)
br label %35
35: ; preds = %33, %2
ret i32 0
}