#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(int /*<<< orphan*/, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ getenv(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ strcat(int /*<<< orphan*/, char *);
void setConsumerSecret(char *key) {
  FILE *fp = fopen(strcat(getenv("HOME"), "/.tweet/consumersecret"), "w");
  if (fp == NULL) {
    perror("Write Error:");
  } else {
    fputs(key, fp);
    fclose(fp);
  }
}


x86 assembly (clang, -O0):
<setConsumerSecret>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe8d(%rip),%rdi
call   1030 <getenv@plt>
mov    %eax,%edi
lea    0xe84(%rip),%rsi
call   1080 <strcat@plt>
mov    %eax,%edi
lea    0xe8d(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11b4 <setConsumerSecret+0x54>
lea    0xe74(%rip),%rdi
call   1070 <perror@plt>
jmp    11ca <setConsumerSecret+0x6a>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <fputs@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setConsumerSecret>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xe92(%rip),%rdi
call   1030 <getenv@plt>
lea    0xe8b(%rip),%rsi
mov    %eax,%edi
call   1080 <strcat@plt>
lea    0xe94(%rip),%rsi
mov    %eax,%edi
call   1060 <fopen@plt>
test   %rax,%rax
je     11b1 <setConsumerSecret+0x51>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1050 <fputs@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <fclose@plt>
lea    0xe66(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1070 <perror@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"HOME\00"
@.str.1 = [23 x i8] c"/.tweet/consumersecret\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [13 x i8] c"Write Error:\00"
define void @setConsumerSecret(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
store i8* %0, i8** %2
%4 = call i32 @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @strcat(i32 %4, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32* @fopen(i32 %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %6, i32** %3
%7 = load i32*, i32** %3
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %17
11: ; preds = %1
%12 = load i8*, i8** %2
%13 = load i32*, i32** %3
%14 = call i32 @fputs(i8* %12, i32* %13)
%15 = load i32*, i32** %3
%16 = call i32 @fclose(i32* %15)
br label %17
17: ; preds = %11, %9
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"HOME\00"
@.str.1 = [23 x i8] c"/.tweet/consumersecret\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [13 x i8] c"Write Error:\00"
define void @setConsumerSecret(i8* nocapture %0) {
%2 = tail call i32 @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @strcat(i32 %2, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32* @fopen(i32 %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = tail call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %11
8: ; preds = %1
%9 = tail call i32 @fputs(i8* %0, i32* %4)
%10 = tail call i32 @fclose(i32* %4)
br label %11
11: ; preds = %8, %6
ret void
}