#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 getEventCode(char *buffer) {
  char tempBuf[10];
  int i = 0, j;
  while (buffer[i] != '-')
    i++;
  j = 0;
  while (buffer[i] != '\0') {
    tempBuf[j++] = buffer[i++];
  }
  tempBuf[j] = '\0';
  return atoi(tempBuf);
}


x86 assembly (clang, -O0):
<getEventCode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2d,%eax
je     1146 <getEventCode+0x36>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1123 <getEventCode+0x13>
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     118d <getEventCode+0x7d>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x18(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%cl
mov    -0x1c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
cltq
mov    %cl,-0x12(%rbp,%rax,1)
jmp    114d <getEventCode+0x3d>
movslq -0x1c(%rbp),%rax
movb   $0x0,-0x12(%rbp,%rax,1)
lea    -0x12(%rbp),%rdi
call   1030 <atoi@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getEventCode>:
sub    $0x18,%rsp
mov    $0xffffffffffffffff,%rcx
nopl   0x0(%rax,%rax,1)
cmpb   $0x2d,0x1(%rdi,%rcx,1)
lea    0x1(%rcx),%rcx
jne    1120 <getEventCode+0x10>
mov    %ecx,%eax
mov    (%rdi,%rax,1),%al
test   %al,%al
je     1154 <getEventCode+0x44>
mov    %ecx,%ecx
add    %rdi,%rcx
add    $0x1,%rcx
xor    %edx,%edx
nop
mov    %al,0xe(%rsp,%rdx,1)
movzbl (%rcx,%rdx,1),%eax
add    $0x1,%rdx
test   %al,%al
jne    1140 <getEventCode+0x30>
mov    %edx,%eax
jmp    1156 <getEventCode+0x46>
xor    %eax,%eax
movb   $0x0,0xe(%rsp,%rax,1)
lea    0xe(%rsp),%rdi
call   1030 <atoi@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
define i32 @getEventCode(i8* %0) {
%2 = alloca i8*
%3 = alloca [10 x i8]
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %4
br label %6
6: ; preds = %14, %1
%7 = load i8*, i8** %2
%8 = load i32, i32* %4
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %7, i64 %9
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 45
br i1 %13, label %14, label %17
14: ; preds = %6
%15 = load i32, i32* %4
%16 = add nsw i32 %15, 1
store i32 %16, i32* %4
br label %6
17: ; preds = %6
store i32 0, i32* %5
br label %18
18: ; preds = %26, %17
%19 = load i8*, i8** %2
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %37
26: ; preds = %18
%27 = load i8*, i8** %2
%28 = load i32, i32* %4
%29 = add nsw i32 %28, 1
store i32 %29, i32* %4
%30 = sext i32 %28 to i64
%31 = getelementptr inbounds i8, i8* %27, i64 %30
%32 = load i8, i8* %31
%33 = load i32, i32* %5
%34 = add nsw i32 %33, 1
store i32 %34, i32* %5
%35 = sext i32 %33 to i64
%36 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 %35
store i8 %32, i8* %36
br label %18
37: ; preds = %18
%38 = load i32, i32* %5
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 %39
store i8 0, i8* %40
%41 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%42 = call i32 @atoi(i8* %41)
ret i32 %42
}

LLVM IR (-O2):
define i32 @getEventCode(i8* nocapture %0) {
%2 = alloca [10 x i8]
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
br label %4
4: ; preds = %4, %1
%5 = phi i64 [ %9, %4 ], [ 0, %1 ]
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 45
%9 = add nuw i64 %5, 1
br i1 %8, label %10, label %4
10: ; preds = %4
%11 = and i64 %5, 4294967295
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
br i1 %14, label %27, label %15
15: ; preds = %10, %15
%16 = phi i64 [ %19, %15 ], [ %11, %10 ]
%17 = phi i64 [ %20, %15 ], [ 0, %10 ]
%18 = phi i8 [ %23, %15 ], [ %13, %10 ]
%19 = add nuw i64 %16, 1
%20 = add nuw i64 %17, 1
%21 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 %17
store i8 %18, i8* %21
%22 = getelementptr inbounds i8, i8* %0, i64 %19
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 0
br i1 %24, label %25, label %15
25: ; preds = %15
%26 = and i64 %20, 4294967295
br label %27
27: ; preds = %25, %10
%28 = phi i64 [ 0, %10 ], [ %26, %25 ]
%29 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 %28
store i8 0, i8* %29
%30 = call i32 @atoi(i8* %3)
ret i32 %30
}