#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*/ addition(char *, int, char *, int);
int /*<<< orphan*/ char_to_int(char *, int);
int /*<<< orphan*/ multiplication(char *, int, char *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
int /*<<< orphan*/ subtraction(char *, int, char *, int);
int main() {
  char a[100], b[100];
  int a_len, b_len;
  int error = 0;
  do {
    if (error)
      printf("ERROR INPUT, a must bigger than b!!\n");
    error = 1;
    printf("Input a:");
    scanf("%s", a);
    printf("Input b:");
    scanf("%s", b);
    a_len = strlen(a);
    b_len = strlen(b);
  } while (a_len < b_len || (a_len == b_len && strcmp(a, b) < 0));
  char_to_int(a, a_len);
  char_to_int(b, b_len);
  printf("a+b=");
  addition(a, a_len, b, b_len);
  printf("a-b=");
  subtraction(a, a_len, b, b_len);
  printf("a*b=");
  multiplication(a, a_len, b, b_len);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xec(%rbp)
cmpl   $0x0,-0xec(%rbp)
je     11b5 <main+0x35>
lea    0xe50(%rip),%rdi
call   1060 <printf@plt>
movl   $0x1,-0xec(%rbp)
lea    0xe5f(%rip),%rdi
call   1060 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xe58(%rip),%rdi
call   10a0 <scanf@plt>
lea    0xe4f(%rip),%rdi
call   1060 <printf@plt>
lea    -0xe0(%rbp),%rsi
lea    0xe39(%rip),%rdi
call   10a0 <scanf@plt>
lea    -0x70(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0xe4(%rbp)
lea    -0xe0(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0xe8(%rbp)
mov    -0xe4(%rbp),%ecx
mov    $0x1,%al
cmp    -0xe8(%rbp),%ecx
mov    %al,-0xed(%rbp)
jl     1278 <main+0xf8>
mov    -0xe4(%rbp),%ecx
xor    %eax,%eax
cmp    -0xe8(%rbp),%ecx
mov    %al,-0xee(%rbp)
jne    126c <main+0xec>
lea    -0x70(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
setl   %al
mov    %al,-0xee(%rbp)
mov    -0xee(%rbp),%al
mov    %al,-0xed(%rbp)
mov    -0xed(%rbp),%al
test   $0x1,%al
jne    119c <main+0x1c>
lea    -0x70(%rbp),%rdi
mov    -0xe4(%rbp),%esi
call   1080 <char_to_int@plt>
lea    -0xe0(%rbp),%rdi
mov    -0xe8(%rbp),%esi
call   1080 <char_to_int@plt>
lea    0xd8c(%rip),%rdi
call   1060 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    -0xe4(%rbp),%esi
lea    -0xe0(%rbp),%rdx
mov    -0xe8(%rbp),%ecx
call   1030 <addition@plt>
lea    0xd69(%rip),%rdi
call   1060 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    -0xe4(%rbp),%esi
lea    -0xe0(%rbp),%rdx
mov    -0xe8(%rbp),%ecx
call   1090 <subtraction@plt>
lea    0xd46(%rip),%rdi
call   1060 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    -0xe4(%rbp),%esi
lea    -0xe0(%rbp),%rdx
mov    -0xe8(%rbp),%ecx
call   1050 <multiplication@plt>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
lea    0xe61(%rip),%r15
lea    0x70(%rsp),%r12
lea    0xe58(%rip),%r13
mov    %rsp,%r14
jmp    11cc <main+0x3c>
nopl   0x0(%rax)
lea    0xe5d(%rip),%rdi
call   1040 <puts@plt>
lea    0xe2d(%rip),%rdi
call   1070 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   10b0 <scanf@plt>
mov    %r13,%rdi
call   1070 <printf@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   10b0 <scanf@plt>
mov    %r12,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1050 <strlen@plt>
cmp    %eax,%ebx
jl     11c0 <main+0x30>
jne    1222 <main+0x92>
mov    %r12,%rdi
mov    %r14,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
js     11c0 <main+0x30>
mov    %ebx,%ebp
jmp    1224 <main+0x94>
mov    %eax,%ebp
lea    0x70(%rsp),%r14
mov    %r14,%rdi
mov    %ebx,%esi
call   1090 <char_to_int@plt>
mov    %rsp,%r15
mov    %r15,%rdi
mov    %ebp,%esi
call   1090 <char_to_int@plt>
lea    0xdce(%rip),%rdi
call   1070 <printf@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %r15,%rdx
mov    %ebp,%ecx
call   1030 <addition@plt>
lea    0xdb8(%rip),%rdi
call   1070 <printf@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %r15,%rdx
mov    %ebp,%ecx
call   10a0 <subtraction@plt>
lea    0xda2(%rip),%rdi
call   1070 <printf@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %r15,%rdx
mov    %ebp,%ecx
call   1060 <multiplication@plt>
xor    %eax,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [37 x i8] c"ERROR INPUT, a must bigger than b!!\0A\00"
@.str.1 = [9 x i8] c"Input a:\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [9 x i8] c"Input b:\00"
@.str.4 = [5 x i8] c"a+b=\00"
@.str.5 = [5 x i8] c"a-b=\00"
@.str.6 = [5 x i8] c"a*b=\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %6
br label %7
7: ; preds = %38, %0
%8 = load i32, i32* %6
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %7
store i32 1, i32* %6
%13 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %17)
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%20 = call i32 @strlen(i8* %19)
store i32 %20, i32* %4
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%22 = call i32 @strlen(i8* %21)
store i32 %22, i32* %5
br label %23
23: ; preds = %12
%24 = load i32, i32* %4
%25 = load i32, i32* %5
%26 = icmp slt i32 %24, %25
br i1 %26, label %38, label %27
27: ; preds = %23
%28 = load i32, i32* %4
%29 = load i32, i32* %5
%30 = icmp eq i32 %28, %29
br i1 %30, label %31, label %36
31: ; preds = %27
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%33 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%34 = call i64 @strcmp(i8* %32, i8* %33)
%35 = icmp slt i64 %34, 0
br label %36
36: ; preds = %31, %27
%37 = phi i1 [ false, %27 ], [ %35, %31 ]
br label %38
38: ; preds = %36, %23
%39 = phi i1 [ true, %23 ], [ %37, %36 ]
br i1 %39, label %7, label %40
40: ; preds = %38
%41 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%42 = load i32, i32* %4
%43 = call i32 @char_to_int(i8* %41, i32 %42)
%44 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%45 = load i32, i32* %5
%46 = call i32 @char_to_int(i8* %44, i32 %45)
%47 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%48 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%49 = load i32, i32* %4
%50 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%51 = load i32, i32* %5
%52 = call i32 @addition(i8* %48, i32 %49, i8* %50, i32 %51)
%53 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%54 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%55 = load i32, i32* %4
%56 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%57 = load i32, i32* %5
%58 = call i32 @subtraction(i8* %54, i32 %55, i8* %56, i32 %57)
%59 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%60 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%61 = load i32, i32* %4
%62 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%63 = load i32, i32* %5
%64 = call i32 @multiplication(i8* %60, i32 %61, i8* %62, i32 %63)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [9 x i8] c"Input a:\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [9 x i8] c"Input b:\00"
@.str.4 = [5 x i8] c"a+b=\00"
@.str.5 = [5 x i8] c"a-b=\00"
@.str.6 = [5 x i8] c"a*b=\00"
@str = [36 x i8] c"ERROR INPUT, a must bigger than b!!\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
br label %7
5: ; preds = %17, %7
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
br label %7
7: ; preds = %0, %5
%8 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%10 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%12 = call i32 @strlen(i8* %3)
%13 = call i32 @strlen(i8* %4)
%14 = icmp slt i32 %12, %13
br i1 %14, label %5, label %15
15: ; preds = %7
%16 = icmp eq i32 %12, %13
br i1 %16, label %17, label %20
17: ; preds = %15
%18 = call i64 @strcmp(i8* %3, i8* %4)
%19 = icmp slt i64 %18, 0
br i1 %19, label %5, label %20
20: ; preds = %15, %17
%21 = phi i32 [ %13, %15 ], [ %12, %17 ]
%22 = call i32 @char_to_int(i8* %3, i32 %12)
%23 = call i32 @char_to_int(i8* %4, i32 %21)
%24 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%25 = call i32 @addition(i8* %3, i32 %12, i8* %4, i32 %21)
%26 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%27 = call i32 @subtraction(i8* %3, i32 %12, i8* %4, i32 %21)
%28 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%29 = call i32 @multiplication(i8* %3, i32 %12, i8* %4, i32 %21)
ret i32 0
}