#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 EOF;
int /*<<< orphan*/ die(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fputs(char const *, int /*<<< orphan*/ *);
void setflash(const char *message) {
  FILE *fh;
  int status;
  fh = fopen("/tmp/ledcolor.txt", "w");
  if (!fh) {
    die("Error opening file '"
        "/tmp/ledcolor.txt"
        "' for writing.");
  }
  status = fputs(message, fh);
  if (status == EOF) {
    die("Error writing to file '"
        "/tmp/ledcolor.txt"
        "'.");
  }
  fclose(fh);
}


x86 assembly (clang, -O0):
<setflash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xead(%rip),%rdi
lea    0xeb8(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    117a <setflash+0x3a>
lea    0xe9f(%rip),%rdi
call   1060 <die@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <fputs@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e54(%rip),%rcx
cmp    (%rcx),%eax
jne    11a8 <setflash+0x68>
lea    0xea5(%rip),%rdi
call   1060 <die@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setflash>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xeb2(%rip),%rdi
lea    0xebd(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    116e <setflash+0x2e>
lea    0xeab(%rip),%rdi
call   1060 <die@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <fputs@plt>
mov    0x2e68(%rip),%rcx
cmp    (%rcx),%eax
jne    1190 <setflash+0x50>
lea    0xebd(%rip),%rdi
call   1060 <die@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"/tmp/ledcolor.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [52 x i8] c"Error opening file '/tmp/ledcolor.txt' for writing.\00"
@EOF = global i32 0
@.str.3 = [43 x i8] c"Error writing to file '/tmp/ledcolor.txt'.\00"
define void @setflash(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32
store i8* %0, i8** %2
%5 = call i32* @fopen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %5, i32** %3
%6 = load i32*, i32** %3
%7 = icmp ne i32* %6, null
br i1 %7, label %10, label %8
8: ; preds = %1
%9 = call i32 @die(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0))
br label %10
10: ; preds = %8, %1
%11 = load i8*, i8** %2
%12 = load i32*, i32** %3
%13 = call i32 @fputs(i8* %11, i32* %12)
store i32 %13, i32* %4
%14 = load i32, i32* %4
%15 = load i32, i32* @EOF
%16 = icmp eq i32 %14, %15
br i1 %16, label %17, label %19
17: ; preds = %10
%18 = call i32 @die(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0))
br label %19
19: ; preds = %17, %10
%20 = load i32*, i32** %3
%21 = call i32 @fclose(i32* %20)
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"/tmp/ledcolor.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [52 x i8] c"Error opening file '/tmp/ledcolor.txt' for writing.\00"
@EOF = global i32 0
@.str.3 = [43 x i8] c"Error writing to file '/tmp/ledcolor.txt'.\00"
define void @setflash(i8* nocapture %0) {
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @die(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0))
br label %6
6: ; preds = %4, %1
%7 = tail call i32 @fputs(i8* %0, i32* %2)
%8 = load i32, i32* @EOF
%9 = icmp eq i32 %7, %8
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = tail call i32 @die(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0))
br label %12
12: ; preds = %10, %6
%13 = tail call i32 @fclose(i32* %2)
ret void
}