#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 EOF;
int fscanf(int /*<<< orphan*/ *, char *, ...);
void *malloc(int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char **read_config_file(FILE *f, int *num_of_params) {
  char a[2000];
  char b[10];
  int ret, ret2;
  char **argv;
  int n;
  argv = malloc((200 + 1) * sizeof(char *));
  if (argv == NULL)
    return NULL;
  for (n = 0; n <= 200; n++)
    argv[n] = NULL;
  n = 1;
  while (n <= 200) {
    ret2 = fscanf(f, " %[\"]", b);
    if (ret2 == 0) {
      ret = fscanf(f, " %s", a);
      if (ret < 1 || ret == EOF)
        break;
      if (a[0] == ';') {
        fscanf(f, "%[^\n]", a);
        continue;
      }
    } else {
      ret = fscanf(f, "%[^\",\n]", a);
      if (ret < 1 || ret == EOF)
        break;
      fscanf(f, "\"");
    }
    argv[n] = malloc((strlen(a) + 1) * sizeof(char));
    if (argv[n] == NULL) {
      return NULL;
    }
    strcpy(argv[n], a);
    n++;
  }
  *num_of_params = n;
  return argv;
}


x86 assembly (clang, -O0):
<read_config_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    $0x648,%edi
call   1060 <malloc@plt>
mov    %rax,-0x810(%rbp)
cmpq   $0x0,-0x810(%rbp)
jne    117f <read_config_file+0x3f>
movq   $0x0,-0x8(%rbp)
jmp    137a <read_config_file+0x23a>
movl   $0x0,-0x814(%rbp)
cmpl   $0xc8,-0x814(%rbp)
jg     11c3 <read_config_file+0x83>
mov    -0x810(%rbp),%rax
movslq -0x814(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x814(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x814(%rbp)
jmp    1189 <read_config_file+0x49>
movl   $0x1,-0x814(%rbp)
cmpl   $0xc8,-0x814(%rbp)
jg     1363 <read_config_file+0x223>
mov    -0x10(%rbp),%rdi
lea    -0x7fa(%rbp),%rdx
lea    0xe11(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    %eax,-0x804(%rbp)
cmpl   $0x0,-0x804(%rbp)
jne    1282 <read_config_file+0x142>
mov    -0x10(%rbp),%rdi
lea    -0x7f0(%rbp),%rdx
lea    0xdeb(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    %eax,-0x800(%rbp)
cmpl   $0x1,-0x800(%rbp)
jl     124a <read_config_file+0x10a>
mov    -0x800(%rbp),%eax
mov    0x2da6(%rip),%rcx
cmp    (%rcx),%eax
jne    124f <read_config_file+0x10f>
jmp    1363 <read_config_file+0x223>
movsbl -0x7f0(%rbp),%eax
cmp    $0x3b,%eax
jne    127d <read_config_file+0x13d>
mov    -0x10(%rbp),%rdi
lea    -0x7f0(%rbp),%rdx
lea    0xd99(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
jmp    11cd <read_config_file+0x8d>
jmp    12da <read_config_file+0x19a>
mov    -0x10(%rbp),%rdi
lea    -0x7f0(%rbp),%rdx
lea    0xd7c(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    %eax,-0x800(%rbp)
cmpl   $0x1,-0x800(%rbp)
jl     12c3 <read_config_file+0x183>
mov    -0x800(%rbp),%eax
mov    0x2d2d(%rip),%rcx
cmp    (%rcx),%eax
jne    12c8 <read_config_file+0x188>
jmp    1363 <read_config_file+0x223>
mov    -0x10(%rbp),%rdi
lea    0xd45(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
lea    -0x7f0(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,%rdx
mov    -0x810(%rbp),%rax
movslq -0x814(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x810(%rbp),%rax
movslq -0x814(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    1331 <read_config_file+0x1f1>
movq   $0x0,-0x8(%rbp)
jmp    137a <read_config_file+0x23a>
mov    -0x810(%rbp),%rax
movslq -0x814(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x7f0(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x814(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x814(%rbp)
jmp    11cd <read_config_file+0x8d>
mov    -0x814(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x810(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_config_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x808,%rsp
mov    %rsi,%rbp
mov    %rdi,%rbx
mov    $0x648,%edi
call   1070 <malloc@plt>
test   %rax,%rax
je     12bc <read_config_file+0x16c>
mov    %rbp,0x18(%rsp)
mov    $0x648,%edx
mov    %rax,0x8(%rsp)
mov    %rax,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
mov    $0x1,%bpl
mov    $0x1,%eax
mov    %rax,0x10(%rsp)
lea    0xe59(%rip),%r12
lea    0x26(%rsp),%r13
lea    0x30(%rsp),%r14
mov    0x2e30(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1060 <fscanf@plt>
mov    %rbx,%rdi
test   %eax,%eax
jne    121f <read_config_file+0xcf>
lea    0xe28(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1060 <fscanf@plt>
test   %eax,%eax
jle    12a9 <read_config_file+0x159>
cmp    (%r15),%eax
je     12a9 <read_config_file+0x159>
cmpb   $0x3b,0x30(%rsp)
jne    124a <read_config_file+0xfa>
mov    %rbx,%rdi
lea    0xe00(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1060 <fscanf@plt>
test   $0x1,%bpl
jne    11c0 <read_config_file+0x70>
jmp    12a9 <read_config_file+0x159>
lea    0xdea(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1060 <fscanf@plt>
test   %eax,%eax
jle    12a9 <read_config_file+0x159>
cmp    (%r15),%eax
je     12a9 <read_config_file+0x159>
mov    %rbx,%rdi
lea    0xdd5(%rip),%rsi
xor    %eax,%eax
call   1060 <fscanf@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%edi
call   1070 <malloc@plt>
mov    0x8(%rsp),%rcx
mov    0x10(%rsp),%rbp
mov    %rax,(%rcx,%rbp,8)
test   %rax,%rax
je     12bc <read_config_file+0x16c>
mov    %rax,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
cmp    $0xc8,%rbp
lea    0x1(%rbp),%rax
setb   %bpl
mov    %rax,0x10(%rsp)
cmp    $0xc9,%rax
jne    11c0 <read_config_file+0x70>
mov    $0xc9,%edx
mov    0x8(%rsp),%rax
mov    0x18(%rsp),%rcx
jmp    12b8 <read_config_file+0x168>
mov    0x8(%rsp),%rax
mov    0x18(%rsp),%rcx
mov    0x10(%rsp),%rdx
mov    %edx,(%rcx)
jmp    12be <read_config_file+0x16e>
xor    %eax,%eax
add    $0x808,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c" %[\22]\00"
@.str.1 = [4 x i8] c" %s\00"
@EOF = global i32 0
@.str.2 = [6 x i8] c"%[^\0A]\00"
@.str.3 = [8 x i8] c"%[^\22,\0A]\00"
@.str.4 = [2 x i8] c"\22\00"
define i8** @read_config_file(i32* %0, i32* %1) {
%3 = alloca i8**
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca [2000 x i8]
%7 = alloca [10 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8**
%11 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
%12 = call i8* @malloc(i32 1608)
%13 = bitcast i8* %12 to i8**
store i8** %13, i8*** %10
%14 = load i8**, i8*** %10
%15 = icmp eq i8** %14, null
br i1 %15, label %16, label %17
16: ; preds = %2
store i8** null, i8*** %3
br label %107
17: ; preds = %2
store i32 0, i32* %11
br label %18
18: ; preds = %26, %17
%19 = load i32, i32* %11
%20 = icmp sle i32 %19, 200
br i1 %20, label %21, label %29
21: ; preds = %18
%22 = load i8**, i8*** %10
%23 = load i32, i32* %11
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8*, i8** %22, i64 %24
store i8* null, i8** %25
br label %26
26: ; preds = %21
%27 = load i32, i32* %11
%28 = add nsw i32 %27, 1
store i32 %28, i32* %11
br label %18
29: ; preds = %18
store i32 1, i32* %11
br label %30
30: ; preds = %93, %55, %29
%31 = load i32, i32* %11
%32 = icmp sle i32 %31, 200
br i1 %32, label %33, label %103
33: ; preds = %30
%34 = load i32*, i32** %4
%35 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
%36 = call i32 (i32*, i8*, ...) @fscanf(i32* %34, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %35)
store i32 %36, i32* %9
%37 = load i32, i32* %9
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %60
39: ; preds = %33
%40 = load i32*, i32** %4
%41 = getelementptr inbounds [2000 x i8], [2000 x i8]* %6, i64 0, i64 0
%42 = call i32 (i32*, i8*, ...) @fscanf(i32* %40, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %41)
store i32 %42, i32* %8
%43 = load i32, i32* %8
%44 = icmp slt i32 %43, 1
br i1 %44, label %49, label %45
45: ; preds = %39
%46 = load i32, i32* %8
%47 = load i32, i32* @EOF
%48 = icmp eq i32 %46, %47
br i1 %48, label %49, label %50
49: ; preds = %45, %39
br label %103
50: ; preds = %45
%51 = getelementptr inbounds [2000 x i8], [2000 x i8]* %6, i64 0, i64 0
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = icmp eq i32 %53, 59
br i1 %54, label %55, label %59
55: ; preds = %50
%56 = load i32*, i32** %4
%57 = getelementptr inbounds [2000 x i8], [2000 x i8]* %6, i64 0, i64 0
%58 = call i32 (i32*, i8*, ...) @fscanf(i32* %56, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %57)
br label %30
59: ; preds = %50
br label %74
60: ; preds = %33
%61 = load i32*, i32** %4
%62 = getelementptr inbounds [2000 x i8], [2000 x i8]* %6, i64 0, i64 0
%63 = call i32 (i32*, i8*, ...) @fscanf(i32* %61, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %62)
store i32 %63, i32* %8
%64 = load i32, i32* %8
%65 = icmp slt i32 %64, 1
br i1 %65, label %70, label %66
66: ; preds = %60
%67 = load i32, i32* %8
%68 = load i32, i32* @EOF
%69 = icmp eq i32 %67, %68
br i1 %69, label %70, label %71
70: ; preds = %66, %60
br label %103
71: ; preds = %66
%72 = load i32*, i32** %4
%73 = call i32 (i32*, i8*, ...) @fscanf(i32* %72, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %74
74: ; preds = %71, %59
%75 = getelementptr inbounds [2000 x i8], [2000 x i8]* %6, i64 0, i64 0
%76 = call i32 @strlen(i8* %75)
%77 = add nsw i32 %76, 1
%78 = sext i32 %77 to i64
%79 = mul i64 %78, 1
%80 = trunc i64 %79 to i32
%81 = call i8* @malloc(i32 %80)
%82 = load i8**, i8*** %10
%83 = load i32, i32* %11
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds i8*, i8** %82, i64 %84
store i8* %81, i8** %85
%86 = load i8**, i8*** %10
%87 = load i32, i32* %11
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds i8*, i8** %86, i64 %88
%90 = load i8*, i8** %89
%91 = icmp eq i8* %90, null
br i1 %91, label %92, label %93
92: ; preds = %74
store i8** null, i8*** %3
br label %107
93: ; preds = %74
%94 = load i8**, i8*** %10
%95 = load i32, i32* %11
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds i8*, i8** %94, i64 %96
%98 = load i8*, i8** %97
%99 = getelementptr inbounds [2000 x i8], [2000 x i8]* %6, i64 0, i64 0
%100 = call i32 @strcpy(i8* %98, i8* %99)
%101 = load i32, i32* %11
%102 = add nsw i32 %101, 1
store i32 %102, i32* %11
br label %30
103: ; preds = %70, %49, %30
%104 = load i32, i32* %11
%105 = load i32*, i32** %5
store i32 %104, i32* %105
%106 = load i8**, i8*** %10
store i8** %106, i8*** %3
br label %107
107: ; preds = %103, %92, %16
%108 = load i8**, i8*** %3
ret i8** %108
}

LLVM IR (-O2):
@.str = [6 x i8] c" %[\22]\00"
@.str.1 = [4 x i8] c" %s\00"
@EOF = global i32 0
@.str.2 = [6 x i8] c"%[^\0A]\00"
@.str.3 = [8 x i8] c"%[^\22,\0A]\00"
@.str.4 = [2 x i8] c"\22\00"
define noalias i8** @read_config_file(i32* nocapture %0, i32* nocapture writeonly %1) {
%3 = alloca [2000 x i8]
%4 = alloca [10 x i8]
%5 = getelementptr inbounds [2000 x i8], [2000 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%7 = tail call dereferenceable_or_null(1608) i8* @malloc(i32 1608)
%8 = bitcast i8* %7 to i8**
%9 = icmp eq i8* %7, null
br i1 %9, label %53, label %10
10: ; preds = %2
br label %44
11: ; preds = %44, %23
%12 = call i32 (i32*, i8*, ...) @fscanf(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %6)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %25
14: ; preds = %11
%15 = call i32 (i32*, i8*, ...) @fscanf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%16 = icmp slt i32 %15, 1
%17 = load i32, i32* @EOF
%18 = icmp eq i32 %15, %17
%19 = select i1 %16, i1 true, i1 %18
br i1 %19, label %47, label %20
20: ; preds = %14
%21 = load i8, i8* %5
%22 = icmp eq i8 %21, 59
br i1 %22, label %23, label %33
23: ; preds = %20
%24 = call i32 (i32*, i8*, ...) @fscanf(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %5)
br i1 %46, label %11, label %47
25: ; preds = %11
%26 = call i32 (i32*, i8*, ...) @fscanf(i32* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %5)
%27 = icmp slt i32 %26, 1
%28 = load i32, i32* @EOF
%29 = icmp eq i32 %26, %28
%30 = select i1 %27, i1 true, i1 %29
br i1 %30, label %49, label %31
31: ; preds = %25
%32 = call i32 (i32*, i8*, ...) @fscanf(i32* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %33
33: ; preds = %20, %31
%34 = call i32 @strlen(i8* %5)
%35 = add nsw i32 %34, 1
%36 = call i8* @malloc(i32 %35)
%37 = getelementptr inbounds i8*, i8** %8, i64 %45
store i8* %36, i8** %37
%38 = icmp eq i8* %36, null
br i1 %38, label %53, label %39
39: ; preds = %33
%40 = call i32 @strcpy(i8* %36, i8* %5)
%41 = add nuw nsw i64 %45, 1
%42 = icmp ult i64 %45, 200
%43 = icmp eq i64 %41, 201
br i1 %43, label %51, label %44
44: ; preds = %10, %39
%45 = phi i64 [ 1, %10 ], [ %41, %39 ]
%46 = phi i1 [ true, %10 ], [ %42, %39 ]
br label %11
47: ; preds = %14, %23
%48 = trunc i64 %45 to i32
br label %51
49: ; preds = %25
%50 = trunc i64 %45 to i32
br label %51
51: ; preds = %39, %49, %47
%52 = phi i32 [ %48, %47 ], [ %50, %49 ], [ 201, %39 ]
store i32 %52, i32* %1
br label %53
53: ; preds = %33, %2, %51
%54 = phi i8** [ %8, %51 ], [ null, %2 ], [ null, %33 ]
ret i8** %54
}