#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 char FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(char *);
char *fopen(char *, char *);
int /*<<< orphan*/ fprintf(char *, char *, long);
int /*<<< orphan*/ printf(char *, char *);
void writelongparam(char *fname, long parm) {
  FILE *tmp;
  tmp = fopen(fname, "w");
  if (tmp == NULL) {
    printf("Error '%s'", tmp);
    return;
  }
  fprintf(tmp, "%lu\n", parm);
  fclose(tmp);
}


x86 assembly (clang, -O0):
<writelongparam>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea5(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1184 <writelongparam+0x44>
mov    -0x18(%rbp),%rsi
lea    0xe88(%rip),%rdi
call   1040 <printf@plt>
jmp    11a1 <writelongparam+0x61>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe7a(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writelongparam>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
lea    0xeb2(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     117c <writelongparam+0x3c>
mov    %rax,%rbx
lea    0xeab(%rip),%rsi
mov    %rax,%rdi
mov    %r14,%rdx
call   1050 <fprintf@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <fclose@plt>
lea    0xe7f(%rip),%rdi
xor    %esi,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"w\00"
@.str.1 = [11 x i8] c"Error '%s'\00"
@.str.2 = [5 x i8] c"%lu\0A\00"
define void @writelongparam(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i8*
store i8* %0, i8** %3
store i64 %1, i64* %4
%6 = load i8*, i8** %3
%7 = call i8* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %7, i8** %5
%8 = load i8*, i8** %5
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i8*, i8** %5
%12 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %11)
br label %19
13: ; preds = %2
%14 = load i8*, i8** %5
%15 = load i64, i64* %4
%16 = call i32 @fprintf(i8* %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %15)
%17 = load i8*, i8** %5
%18 = call i32 @fclose(i8* %17)
br label %19
19: ; preds = %13, %10
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
@.str.1 = [11 x i8] c"Error '%s'\00"
@.str.2 = [5 x i8] c"%lu\0A\00"
define void @writelongparam(i8* nocapture %0, i64 %1) {
%3 = tail call i8* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* null)
br label %10
7: ; preds = %2
%8 = tail call i32 @fprintf(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %1)
%9 = tail call i32 @fclose(i8* %3)
br label %10
10: ; preds = %7, %5
ret void
}