#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*/ config_primary_options();
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ system(char *);
void start_primary_session(void) {
  FILE *fp;
  if ((fp = fopen("/var/run/ppp1.pid", "r")) == NULL) {
    if ((fp = fopen("/tmp/resolv.conf", "w")) != NULL) {
      fputs("", fp);
      fclose(fp);
    }
  } else {
    fclose(fp);
  }
  config_primary_options();
  system("/usr/sbin/pppd call pppoe-session1 updetach");
}


x86 assembly (clang, -O0):
<start_primary_session>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xea1(%rip),%rdi
lea    0xeac(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
jne    11b8 <start_primary_session+0x68>
lea    0xe94(%rip),%rdi
lea    0xe9e(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
je     11b3 <start_primary_session+0x63>
mov    -0x8(%rbp),%rsi
lea    0xe6c(%rip),%rdi
call   1060 <fputs@plt>
mov    -0x8(%rbp),%rdi
call   1040 <fclose@plt>
jmp    11c1 <start_primary_session+0x71>
mov    -0x8(%rbp),%rdi
call   1040 <fclose@plt>
mov    $0x0,%al
call   1030 <config_primary_options@plt>
lea    0xe58(%rip),%rdi
call   1050 <system@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<start_primary_session>:
push   %rax
lea    0xeb8(%rip),%rdi
lea    0xec3(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
jne    1171 <start_primary_session+0x31>
lea    0xeb4(%rip),%rdi
lea    0xebe(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1179 <start_primary_session+0x39>
mov    %rax,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
call   1030 <config_primary_options@plt>
lea    0xea0(%rip),%rdi
pop    %rax
jmp    1050 <system@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"/var/run/ppp1.pid\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [17 x i8] c"/tmp/resolv.conf\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [1 x i8] zeroinitializer
@.str.5 = [44 x i8] c"/usr/sbin/pppd call pppoe-session1 updetach\00"
define void @start_primary_session() {
%1 = alloca i32*
%2 = 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* %2, i32** %1
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %13
4: ; preds = %0
%5 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %5, i32** %1
%6 = icmp ne i32* %5, null
br i1 %6, label %7, label %12
7: ; preds = %4
%8 = load i32*, i32** %1
%9 = call i32 @fputs(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), i32* %8)
%10 = load i32*, i32** %1
%11 = call i32 @fclose(i32* %10)
br label %12
12: ; preds = %7, %4
br label %16
13: ; preds = %0
%14 = load i32*, i32** %1
%15 = call i32 @fclose(i32* %14)
br label %16
16: ; preds = %13, %12
%17 = call i32 (...) @config_primary_options()
%18 = call i32 @system(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"/var/run/ppp1.pid\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [17 x i8] c"/tmp/resolv.conf\00"
@.str.3 = [2 x i8] c"w\00"
@.str.5 = [44 x i8] c"/usr/sbin/pppd call pppoe-session1 updetach\00"
define void @start_primary_session() {
%1 = 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))
%2 = icmp eq i32* %1, null
br i1 %2, label %3, label %6
3: ; preds = %0
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %9, label %6
6: ; preds = %0, %3
%7 = phi i32* [ %4, %3 ], [ %1, %0 ]
%8 = tail call i32 @fclose(i32* %7)
br label %9
9: ; preds = %6, %3
%10 = tail call i32 (...) @config_primary_options()
%11 = tail call i32 @system(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0))
ret void
}