#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 calc(char *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int);
int /*<<< orphan*/ stdout;
scalar_t__ strlen(char *);
int main(int argc, char *argv[]) {
  char buf[] = "9 + (3 - 1) * 2 + 9 / 3 + 1";
  int buf_len = (int)strlen(buf);
  int calc_ret = calc(buf, buf_len);
  fprintf(stdout, "%s = %d\n", buf, calc_ret);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xeb3(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xeb0(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xead(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeab(%rip),%eax
mov    %eax,-0x18(%rbp)
lea    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x34(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   1040 <calc@plt>
mov    %eax,-0x38(%rbp)
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
lea    -0x30(%rbp),%rdx
mov    -0x38(%rbp),%ecx
lea    0xe7a(%rip),%rsi
call   1050 <fprintf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
movups 0xed0(%rip),%xmm0
movups %xmm0,0xc(%rsp)
movaps 0xeb8(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <calc@plt>
mov    0x2e78(%rip),%rcx
mov    (%rcx),%edi
lea    0xeab(%rip),%rsi
mov    %rbx,%rdx
mov    %eax,%ecx
call   1050 <fprintf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.buf = [28 x i8] c"9 + (3 - 1) * 2 + 9 / 3 + 1\00"
@stdout = global i32 0
@.str = [9 x i8] c"%s = %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [28 x i8]
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = bitcast [28 x i8]* %6 to i8*
%10 = getelementptr inbounds [28 x i8], [28 x i8]* %6, i64 0, i64 0
%11 = call i64 @strlen(i8* %10)
%12 = trunc i64 %11 to i32
store i32 %12, i32* %7
%13 = getelementptr inbounds [28 x i8], [28 x i8]* %6, i64 0, i64 0
%14 = load i32, i32* %7
%15 = call i32 @calc(i8* %13, i32 %14)
store i32 %15, i32* %8
%16 = load i32, i32* @stdout
%17 = getelementptr inbounds [28 x i8], [28 x i8]* %6, i64 0, i64 0
%18 = load i32, i32* %8
%19 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %17, i32 %18)
ret i32 0
}

LLVM IR (-O2):
@__const.main.buf = [28 x i8] c"9 + (3 - 1) * 2 + 9 / 3 + 1\00"
@stdout = global i32 0
@.str = [9 x i8] c"%s = %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [28 x i8]
%4 = getelementptr inbounds [28 x i8], [28 x i8]* %3, i64 0, i64 0
%5 = call i64 @strlen(i8* %4)
%6 = trunc i64 %5 to i32
%7 = call i32 @calc(i8* %4, i32 %6)
%8 = load i32, i32* @stdout
%9 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %4, i32 %7)
ret i32 0
}