#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 */
struct num {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ num_free(struct num *);
char *num_string(struct num *);
int /*<<< orphan*/ printf(char *, ...);
struct num *xcalc(char *);
int main(int argc, char **argv) {
  int i;
  struct num *num;
  for (i = 1; i < argc; i++) {
    num = xcalc(argv[i]);
    if (num)
      printf("%s <- %s\n", num_string(num), argv[i]);
    else
      printf("ERR!\n");
    num_free(num);
  }
  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)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11d9 <main+0x99>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <xcalc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11b4 <main+0x74>
mov    -0x20(%rbp),%rdi
call   1060 <num_string@plt>
mov    %rax,%rsi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11c2 <main+0x82>
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <num_free@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115d <main+0x1d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jl     11c5 <main+0x75>
mov    %rsi,%r12
mov    %edi,%r13d
mov    $0x1,%ebp
lea    0xe98(%rip),%r14
lea    0xe87(%rip),%r15
jmp    1199 <main+0x49>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1040 <num_free@plt>
add    $0x1,%rbp
cmp    %rbp,%r13
je     11c5 <main+0x75>
mov    (%r12,%rbp,8),%rdi
call   1060 <xcalc@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1180 <main+0x30>
mov    %rbx,%rdi
call   1070 <num_string@plt>
mov    (%r12,%rbp,8),%rdx
mov    %r15,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1188 <main+0x38>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.num = type { i32 }
@.str = [10 x i8] c"%s <- %s\0A\00"
@.str.1 = [6 x i8] c"ERR!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.num*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
br label %8
8: ; preds = %35, %2
%9 = load i32, i32* %6
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %38
12: ; preds = %8
%13 = load i8**, i8*** %5
%14 = load i32, i32* %6
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8*, i8** %13, i64 %15
%17 = load i8*, i8** %16
%18 = call %struct.num* @xcalc(i8* %17)
store %struct.num* %18, %struct.num** %7
%19 = load %struct.num*, %struct.num** %7
%20 = icmp ne %struct.num* %19, null
br i1 %20, label %21, label %30
21: ; preds = %12
%22 = load %struct.num*, %struct.num** %7
%23 = call i8* @num_string(%struct.num* %22)
%24 = load i8**, i8*** %5
%25 = load i32, i32* %6
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %24, i64 %26
%28 = load i8*, i8** %27
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %23, i8* %28)
br label %32
30: ; preds = %12
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %32
32: ; preds = %30, %21
%33 = load %struct.num*, %struct.num** %7
%34 = call i32 @num_free(%struct.num* %33)
br label %35
35: ; preds = %32
%36 = load i32, i32* %6
%37 = add nsw i32 %36, 1
store i32 %37, i32* %6
br label %8
38: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
%struct.num = type { i32 }
@.str = [10 x i8] c"%s <- %s\0A\00"
@str = [5 x i8] c"ERR!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %22
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %6
6: ; preds = %4, %18
%7 = phi i64 [ 1, %4 ], [ %20, %18 ]
%8 = getelementptr inbounds i8*, i8** %1, i64 %7
%9 = load i8*, i8** %8
%10 = tail call %struct.num* @xcalc(i8* %9)
%11 = icmp eq %struct.num* %10, null
br i1 %11, label %16, label %12
12: ; preds = %6
%13 = tail call i8* @num_string(%struct.num* %10)
%14 = load i8*, i8** %8
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %13, i8* %14)
br label %18
16: ; preds = %6
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
br label %18
18: ; preds = %16, %12
%19 = tail call i32 @num_free(%struct.num* %10)
%20 = add nuw nsw i64 %7, 1
%21 = icmp eq i64 %20, %5
br i1 %21, label %22, label %6
22: ; preds = %18, %2
ret i32 0
}