#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*/ fprintf(int /*<<< orphan*/ *, char *, char *);
void config_status(int unit, char *status) {
  FILE *fd;
  char *status_files[2] = {"/etc/ppp/pppoe1-status", "/etc/ppp/pppoe2-status"};
  if ((fd = fopen(status_files[unit], "w")) != NULL) {
    fprintf(fd, "%s", status);
    fclose(fd);
  }
}


x86 assembly (clang, -O0):
<config_status>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2cca(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2cc7(%rip),%rax
mov    %rax,-0x28(%rbp)
movslq -0x4(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rdi
lea    0xec9(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1195 <config_status+0x65>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xea9(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<config_status>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
movslq %edi,%rax
lea    0xeef(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
lea    0xedf(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     1176 <config_status+0x46>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1040 <fputs@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <fclose@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [23 x i8] c"/etc/ppp/pppoe1-status\00"
@.str.1 = [23 x i8] c"/etc/ppp/pppoe2-status\00"
@__const.config_status.status_files = [2 x i8*] [i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i32 0, i32 0)]
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [3 x i8] c"%s\00"
define void @config_status(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca [2 x i8*]
store i32 %0, i32* %3
store i8* %1, i8** %4
%7 = bitcast [2 x i8*]* %6 to i8*
%8 = load i32, i32* %3
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds [2 x i8*], [2 x i8*]* %6, i64 0, i64 %9
%11 = load i8*, i8** %10
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %12, i32** %5
%13 = icmp ne i32* %12, null
br i1 %13, label %14, label %20
14: ; preds = %2
%15 = load i32*, i32** %5
%16 = load i8*, i8** %4
%17 = call i32 @fprintf(i32* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %16)
%18 = load i32*, i32** %5
%19 = call i32 @fclose(i32* %18)
br label %20
20: ; preds = %14, %2
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"/etc/ppp/pppoe1-status\00"
@.str.1 = [23 x i8] c"/etc/ppp/pppoe2-status\00"
@reltable.config_status = [2 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([23 x i8]* @.str to i64), i64 ptrtoint ([2 x i32]* @reltable.config_status to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([23 x i8]* @.str.1 to i64), i64 ptrtoint ([2 x i32]* @reltable.config_status to i64)) to i32)]
@.str.2 = [2 x i8] c"w\00"
define void @config_status(i32 %0, i8* nocapture %1) {
%3 = sext i32 %0 to i64
%4 = shl i64 %3, 2
%5 = call i8* @llvm.load.relative.i64(i8* bitcast ([2 x i32]* @reltable.config_status to i8*), i64 %4)
%6 = tail call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = tail call i32 @fputs(i8* %1, i32* %6)
%10 = tail call i32 @fclose(i32* %6)
br label %11
11: ; preds = %8, %2
ret void
}