#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 *);
int getchar();
int /*<<< orphan*/ getline(char **, size_t *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  FILE *fp;
  int option;
  size_t len;
  char *buf = NULL;
  printf("This program has two function. Please specify the option \n");
  printf("Choose '1' for writing to the data folder \n");
  printf("Choose '2' for reading from the etc folder \n");
  printf("Your input: ");
  option = getchar();
  if (option == '1') {
    fp = fopen("/opt/container/process2/data/process2_direct.txt", "w");
    if (!fp) {
      printf("Error! \n");
      return 1;
    }
    fprintf(fp, "This file was created by process 2");
  }
  if (option == '2') {
    fp = fopen("/opt/container/process2/etc/boolean.config", "rt");
    if (!fp) {
      printf("Error! \n");
      return 1;
    }
    getline(&buf, &len, fp);
    printf("input: %s\n", buf);
  } else {
    printf("Option not available or wrong input type");
    return 1;
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x28(%rbp)
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeec(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x31,-0x14(%rbp)
jne    120f <main+0xaf>
lea    0xed7(%rip),%rdi
lea    0xf01(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11ff <main+0x9f>
lea    0xee8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12a7 <main+0x147>
mov    -0x10(%rbp),%rdi
lea    0xed3(%rip),%rsi
call   1060 <fprintf@plt>
cmpl   $0x32,-0x14(%rbp)
jne    127d <main+0x11d>
lea    0xee0(%rip),%rdi
lea    0xf04(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1255 <main+0xf5>
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12a7 <main+0x147>
mov    -0x10(%rbp),%rdx
lea    -0x28(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1080 <getline@plt>
mov    -0x28(%rbp),%rsi
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1297 <main+0x137>
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12a7 <main+0x147>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
movq   $0x0,0x8(%rsp)
lea    0xf3f(%rip),%rdi
call   1030 <puts@plt>
lea    0xf6d(%rip),%rdi
call   1030 <puts@plt>
lea    0xf8c(%rip),%rdi
call   1030 <puts@plt>
lea    0xe56(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    $0x32,%eax
je     1203 <main+0x93>
cmp    $0x31,%eax
jne    11f3 <main+0x83>
lea    0xe44(%rip),%rdi
lea    0xe6e(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     124f <main+0xdf>
lea    0xe5f(%rip),%rdi
mov    $0x22,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1090 <fwrite@plt>
lea    0xea2(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    125b <main+0xeb>
lea    0xe59(%rip),%rdi
lea    0xe7d(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     124f <main+0xdf>
mov    %rax,%rbx
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    %rax,%rdx
call   1080 <getline@plt>
mov    0x8(%rsp),%rsi
lea    0xe55(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
jmp    1260 <main+0xf0>
lea    0xf00(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [59 x i8] c"This program has two function. Please specify the option \0A\00"
@.str.1 = [44 x i8] c"Choose '1' for writing to the data folder \0A\00"
@.str.2 = [45 x i8] c"Choose '2' for reading from the etc folder \0A\00"
@.str.3 = [13 x i8] c"Your input: \00"
@.str.4 = [49 x i8] c"/opt/container/process2/data/process2_direct.txt\00"
@.str.5 = [2 x i8] c"w\00"
@.str.6 = [9 x i8] c"Error! \0A\00"
@.str.7 = [35 x i8] c"This file was created by process 2\00"
@.str.8 = [43 x i8] c"/opt/container/process2/etc/boolean.config\00"
@.str.9 = [3 x i8] c"rt\00"
@.str.10 = [11 x i8] c"input: %s\0A\00"
@.str.11 = [41 x i8] c"Option not available or wrong input type\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i64
%5 = alloca i8*
store i32 0, i32* %1
store i8* null, i8** %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 (...) @getchar()
store i32 %10, i32* %3
%11 = load i32, i32* %3
%12 = icmp eq i32 %11, 49
br i1 %12, label %13, label %22
13: ; preds = %0
%14 = call i32* @fopen(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %14, i32** %2
%15 = load i32*, i32** %2
%16 = icmp ne i32* %15, null
br i1 %16, label %19, label %17
17: ; preds = %13
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %1
br label %41
19: ; preds = %13
%20 = load i32*, i32** %2
%21 = call i32 @fprintf(i32* %20, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0))
br label %22
22: ; preds = %19, %0
%23 = load i32, i32* %3
%24 = icmp eq i32 %23, 50
br i1 %24, label %25, label %36
25: ; preds = %22
%26 = call i32* @fopen(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
store i32* %26, i32** %2
%27 = load i32*, i32** %2
%28 = icmp ne i32* %27, null
br i1 %28, label %31, label %29
29: ; preds = %25
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %1
br label %41
31: ; preds = %25
%32 = load i32*, i32** %2
%33 = call i32 @getline(i8** %5, i64* %4, i32* %32)
%34 = load i8*, i8** %5
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0), i8* %34)
br label %38
36: ; preds = %22
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.11, i64 0, i64 0))
store i32 1, i32* %1
br label %41
38: ; preds = %31
%39 = load i32*, i32** %2
%40 = call i32 @fclose(i32* %39)
store i32 0, i32* %1
br label %41
41: ; preds = %38, %36, %29, %17
%42 = load i32, i32* %1
ret i32 %42
}

LLVM IR (-O2):
@.str.3 = [13 x i8] c"Your input: \00"
@.str.4 = [49 x i8] c"/opt/container/process2/data/process2_direct.txt\00"
@.str.5 = [2 x i8] c"w\00"
@.str.7 = [35 x i8] c"This file was created by process 2\00"
@.str.8 = [43 x i8] c"/opt/container/process2/etc/boolean.config\00"
@.str.9 = [3 x i8] c"rt\00"
@.str.10 = [11 x i8] c"input: %s\0A\00"
@.str.11 = [41 x i8] c"Option not available or wrong input type\00"
@str = [58 x i8] c"This program has two function. Please specify the option \00"
@str.12 = [43 x i8] c"Choose '1' for writing to the data folder \00"
@str.13 = [44 x i8] c"Choose '2' for reading from the etc folder \00"
@str.15 = [8 x i8] c"Error! \00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i8*
%3 = bitcast i64* %1 to i8*
%4 = bitcast i8** %2 to i8*
store i8* null, i8** %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.12, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.13, i64 0, i64 0))
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%9 = tail call i32 (...) @getchar()
switch i32 %9, label %27 [
i32 49, label %10
i32 50, label %17
]
10: ; preds = %0
%11 = tail call i32* @fopen(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.15, i64 0, i64 0))
br label %29
15: ; preds = %10
%16 = tail call i64 @fwrite(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0), i64 34, i64 1, i32* %11)
br label %27
17: ; preds = %0
%18 = tail call i32* @fopen(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.15, i64 0, i64 0))
br label %29
22: ; preds = %17
%23 = call i32 @getline(i8** %2, i64* %1, i32* %18)
%24 = load i8*, i8** %2
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0), i8* %24)
%26 = call i32 @fclose(i32* %18)
br label %29
27: ; preds = %15, %0
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.11, i64 0, i64 0))
br label %29
29: ; preds = %22, %27, %20, %13
%30 = phi i32 [ 0, %22 ], [ 1, %20 ], [ 1, %27 ], [ 1, %13 ]
ret i32 %30
}