#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ system(char *);
int create_log_file(void) {
  printf("\nCreate web log file\n");
  FILE *fp;
  if (NULL != (fp = fopen("/home/pi/Web_Log_Files/pid3.txt", "w"))) {
    system("chmod 777 /home/pi/Web_Log_Files/pid3.txt");
    printf("Updated file: /home/pi/Web_Log_Files/pid3.txt\n");
  } else {
    printf("Error creating output data file\n");
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<create_log_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
call   1050 <printf@plt>
lea    0xec7(%rip),%rdi
lea    0xeb4(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rcx
mov    %rcx,-0x8(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
je     1196 <create_log_file+0x56>
lea    0xe98(%rip),%rdi
call   1040 <system@plt>
lea    0xeb6(%rip),%rdi
call   1050 <printf@plt>
jmp    11a2 <create_log_file+0x62>
lea    0xed4(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_log_file>:
push   %rbx
lea    0xee4(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb8(%rip),%rdi
lea    0xea5(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
je     117d <create_log_file+0x3d>
lea    0xe93(%rip),%rdi
call   1050 <system@plt>
lea    0xee6(%rip),%rdi
jmp    1184 <create_log_file+0x44>
lea    0xebd(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [22 x i8] c"\0ACreate web log file\0A\00"
@.str.1 = [32 x i8] c"/home/pi/Web_Log_Files/pid3.txt\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [42 x i8] c"chmod 777 /home/pi/Web_Log_Files/pid3.txt\00"
@.str.4 = [47 x i8] c"Updated file: /home/pi/Web_Log_Files/pid3.txt\0A\00"
@.str.5 = [33 x i8] c"Error creating output data file\0A\00"
define i32 @create_log_file() {
%1 = alloca i32*
%2 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%3 = call i32* @fopen(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %3, i32** %1
%4 = icmp ne i32* null, %3
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = call i32 @system(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0))
br label %10
8: ; preds = %0
%9 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
br label %10
10: ; preds = %8, %5
%11 = load i32*, i32** %1
%12 = call i32 @fclose(i32* %11)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [32 x i8] c"/home/pi/Web_Log_Files/pid3.txt\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [42 x i8] c"chmod 777 /home/pi/Web_Log_Files/pid3.txt\00"
@str = [21 x i8] c"\0ACreate web log file\00"
@str.6 = [32 x i8] c"Error creating output data file\00"
@str.7 = [46 x i8] c"Updated file: /home/pi/Web_Log_Files/pid3.txt\00"
define i32 @create_log_file() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %6, label %4
4: ; preds = %0
%5 = tail call i32 @system(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0))
br label %6
6: ; preds = %0, %4
%7 = phi i8* [ getelementptr inbounds ([46 x i8], [46 x i8]* @str.7, i64 0, i64 0), %4 ], [ getelementptr inbounds ([32 x i8], [32 x i8]* @str.6, i64 0, i64 0), %0 ]
%8 = tail call i32 @puts(i8* dereferenceable(1) %7)
%9 = tail call i32 @fclose(i32* %2)
ret i32 0
}