#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 */
scalar_t__ run_shell_command_with_output(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int program_repo_get_current_checkout(char *repo_dir, char *commit) {
  char commandstr[256];
  commit[0] = 0;
  sprintf(commandstr,
          "cd %s\ngit log -1 | grep commit | awk -F ' ' '{print $2}'",
          repo_dir);
  if (run_shell_command_with_output(commandstr, commit) != 0)
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<program_repo_get_current_checkout>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xeb4(%rip),%rsi
call   1040 <sprintf@plt>
lea    -0x120(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <run_shell_command_with_output@plt>
cmp    $0x0,%rax
je     1177 <program_repo_get_current_checkout+0x57>
movl   $0x1,-0x4(%rbp)
jmp    117e <program_repo_get_current_checkout+0x5e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<program_repo_get_current_checkout>:
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %rsi,%rbx
mov    %rdi,%rdx
movb   $0x0,(%rsi)
lea    0xec6(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
call   1040 <sprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <run_shell_command_with_output@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
mov    %ecx,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [57 x i8] c"cd %s\0Agit log -1 | grep commit | awk -F ' ' '{print $2}'\00"
define i32 @program_repo_get_current_checkout(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [256 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %5
%8 = getelementptr inbounds i8, i8* %7, i64 0
store i8 0, i8* %8
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%10 = load i8*, i8** %4
%11 = call i32 @sprintf(i8* %9, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%13 = load i8*, i8** %5
%14 = call i64 @run_shell_command_with_output(i8* %12, i8* %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %2
store i32 1, i32* %3
br label %18
17: ; preds = %2
store i32 0, i32* %3
br label %18
18: ; preds = %17, %16
%19 = load i32, i32* %3
ret i32 %19
}

LLVM IR (-O2):
@.str = [57 x i8] c"cd %s\0Agit log -1 | grep commit | awk -F ' ' '{print $2}'\00"
define i32 @program_repo_get_current_checkout(i8* %0, i8* %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
store i8 0, i8* %1
%5 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = call i64 @run_shell_command_with_output(i8* %4, i8* %1)
%7 = icmp ne i64 %6, 0
%8 = zext i1 %7 to i32
ret i32 %8
}