#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 check_possible_values(char const *, char const **);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char const *, ...);
void write_into_file(FILE *outfile, const char *opt, const char *arg,
                     const char *values[]) {
  int found = -1;
  if (arg) {
    if (values) {
      found = check_possible_values(arg, values);
    }
    if (found >= 0)
      fprintf(outfile, "%s=\"%s\" # %s\n", opt, arg, values[found]);
    else
      fprintf(outfile, "%s=\"%s\"\n", opt, arg);
  } else {
    fprintf(outfile, "%s\n", opt);
  }
}


x86 assembly (clang, -O0):
<write_into_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0xffffffff,-0x24(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11b9 <write_into_file+0x99>
cmpq   $0x0,-0x20(%rbp)
je     1165 <write_into_file+0x45>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <check_possible_values@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jl     119a <write_into_file+0x7a>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rsi
mov    (%rax,%rsi,8),%r8
lea    0xe72(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11b4 <write_into_file+0x94>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe61(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11cf <write_into_file+0xaf>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe42(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_into_file>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
test   %rdx,%rdx
je     1175 <write_into_file+0x55>
mov    %rcx,%r12
mov    %rdx,%rbx
test   %rcx,%rcx
je     1194 <write_into_file+0x74>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <check_possible_values@plt>
test   %eax,%eax
js     1194 <write_into_file+0x74>
mov    %eax,%eax
mov    (%r12,%rax,8),%r8
lea    0xea6(%rip),%rsi
mov    %r15,%rdi
mov    %r14,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <fprintf@plt>
lea    0xe8e(%rip),%rsi
mov    %r15,%rdi
mov    %r14,%rdx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <fprintf@plt>
lea    0xe73(%rip),%rsi
mov    %r15,%rdi
mov    %r14,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"%s=\22%s\22 # %s\0A\00"
@.str.1 = [9 x i8] c"%s=\22%s\22\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define void @write_into_file(i32* %0, i8* %1, i8* %2, i8** %3) {
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8**
%9 = alloca i32
store i32* %0, i32** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8** %3, i8*** %8
store i32 -1, i32* %9
%10 = load i8*, i8** %7
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %38
12: ; preds = %4
%13 = load i8**, i8*** %8
%14 = icmp ne i8** %13, null
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = load i8*, i8** %7
%17 = load i8**, i8*** %8
%18 = call i32 @check_possible_values(i8* %16, i8** %17)
store i32 %18, i32* %9
br label %19
19: ; preds = %15, %12
%20 = load i32, i32* %9
%21 = icmp sge i32 %20, 0
br i1 %21, label %22, label %32
22: ; preds = %19
%23 = load i32*, i32** %5
%24 = load i8*, i8** %6
%25 = load i8*, i8** %7
%26 = load i8**, i8*** %8
%27 = load i32, i32* %9
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %26, i64 %28
%30 = load i8*, i8** %29
%31 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %23, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %24, i8* %25, i8* %30)
br label %37
32: ; preds = %19
%33 = load i32*, i32** %5
%34 = load i8*, i8** %6
%35 = load i8*, i8** %7
%36 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %33, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %34, i8* %35)
br label %37
37: ; preds = %32, %22
br label %42
38: ; preds = %4
%39 = load i32*, i32** %5
%40 = load i8*, i8** %6
%41 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %39, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %40)
br label %42
42: ; preds = %38, %37
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"%s=\22%s\22 # %s\0A\00"
@.str.1 = [9 x i8] c"%s=\22%s\22\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define void @write_into_file(i32* nocapture %0, i8* %1, i8* %2, i8** %3) {
%5 = icmp eq i8* %2, null
br i1 %5, label %18, label %6
6: ; preds = %4
%7 = icmp eq i8** %3, null
br i1 %7, label %16, label %8
8: ; preds = %6
%9 = tail call i32 @check_possible_values(i8* %2, i8** %3)
%10 = icmp sgt i32 %9, -1
br i1 %10, label %11, label %16
11: ; preds = %8
%12 = zext i32 %9 to i64
%13 = getelementptr inbounds i8*, i8** %3, i64 %12
%14 = load i8*, i8** %13
%15 = tail call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %2, i8* %14)
br label %20
16: ; preds = %6, %8
%17 = tail call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* %2)
br label %20
18: ; preds = %4
%19 = tail call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %1)
br label %20
20: ; preds = %11, %16, %18
ret void
}