#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char const *);
int /*<<< orphan*/ system(char *);
FILE *log_open(const char *filename) {
  FILE *LOG;
  char cmnd[1000];
  sprintf(cmnd, "echo git commit = `git rev-parse HEAD` > %s", filename);
  system(cmnd);
  LOG = fopen(filename, "a");
  if (!LOG) {
    return LOG;
  }
  return LOG;
}


x86 assembly (clang, -O0):
<log_open>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x400(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xeaf(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x400(%rbp),%rdi
call   1030 <system@plt>
mov    -0x10(%rbp),%rdi
lea    0xebf(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    118e <log_open+0x5e>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1196 <log_open+0x66>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<log_open>:
push   %r14
push   %rbx
sub    $0x3e8,%rsp
mov    %rdi,%rbx
lea    0xebc(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
mov    %rbx,%rdx
call   1050 <sprintf@plt>
mov    %r14,%rdi
call   1030 <system@plt>
lea    0xecb(%rip),%rsi
mov    %rbx,%rdi
add    $0x3e8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <fopen@plt>

LLVM IR (-O0):
@.str = [44 x i8] c"echo git commit = `git rev-parse HEAD` > %s\00"
@.str.1 = [2 x i8] c"a\00"
define i32* @log_open(i8* %0) {
%2 = alloca i32*
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca [1000 x i8]
store i8* %0, i8** %3
%6 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%7 = load i8*, i8** %3
%8 = call i32 @sprintf(i8* %6, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%10 = call i32 @system(i8* %9)
%11 = load i8*, i8** %3
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %12, i32** %4
%13 = load i32*, i32** %4
%14 = icmp ne i32* %13, null
br i1 %14, label %17, label %15
15: ; preds = %1
%16 = load i32*, i32** %4
store i32* %16, i32** %2
br label %19
17: ; preds = %1
%18 = load i32*, i32** %4
store i32* %18, i32** %2
br label %19
19: ; preds = %17, %15
%20 = load i32*, i32** %2
ret i32* %20
}

LLVM IR (-O2):
@.str = [44 x i8] c"echo git commit = `git rev-parse HEAD` > %s\00"
@.str.1 = [2 x i8] c"a\00"
define noalias i32* @log_open(i8* %0) {
%2 = alloca [1000 x i8]
%3 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%4 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = call i32 @system(i8* %3)
%6 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret i32* %6
}