#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*/ AppendFormData(char *, char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int sscanf(char *, char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int LoadFormData(char *szFileName) {
  char szLine[1024];
  char szBuff[1024];
  FILE *fp;
  char szName[21];
  if ((fp = fopen(szFileName, "rt")) == NULL) {
    return 0;
  }
  szName[0] = '\0';
  while (fgets(szLine, 1024 - 1, fp)) {
    if (sscanf(szLine, "%s", szBuff) == 1) {
      if (strlen(szBuff) >= 2 && szBuff[0] == '%' && szBuff[1] == '%') {
        strncpy(szName, szBuff + 2, 21 - 1);
        szName[21 - 1] = '\0';
      } else {
        AppendFormData(szName, szLine);
      }
    } else {
      AppendFormData(szName, szLine);
    }
  }
  fclose(fp);
  return 1;
}


x86 assembly (clang, -O0):
<LoadFormData>:
push   %rbp
mov    %rsp,%rbp
sub    $0x830,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe76(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x818(%rbp)
cmp    $0x0,%rax
jne    11ac <LoadFormData+0x3c>
movl   $0x0,-0x4(%rbp)
jmp    1298 <LoadFormData+0x128>
movb   $0x0,-0x830(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x818(%rbp),%rdx
mov    $0x3ff,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     1285 <LoadFormData+0x115>
lea    -0x410(%rbp),%rdi
lea    -0x810(%rbp),%rdx
lea    0xe19(%rip),%rsi
call   1080 <sscanf@plt>
cmp    $0x1,%eax
jne    126d <LoadFormData+0xfd>
lea    -0x810(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x2,%eax
jl     1255 <LoadFormData+0xe5>
movsbl -0x810(%rbp),%eax
cmp    $0x25,%eax
jne    1255 <LoadFormData+0xe5>
movsbl -0x80f(%rbp),%eax
cmp    $0x25,%eax
jne    1255 <LoadFormData+0xe5>
lea    -0x830(%rbp),%rdi
lea    -0x810(%rbp),%rsi
add    $0x2,%rsi
mov    $0x14,%edx
call   1030 <strncpy@plt>
movb   $0x0,-0x81c(%rbp)
jmp    1268 <LoadFormData+0xf8>
lea    -0x830(%rbp),%rdi
lea    -0x410(%rbp),%rsi
call   1070 <AppendFormData@plt>
jmp    1280 <LoadFormData+0x110>
lea    -0x830(%rbp),%rdi
lea    -0x410(%rbp),%rsi
call   1070 <AppendFormData@plt>
jmp    11b3 <LoadFormData+0x43>
mov    -0x818(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x830,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LoadFormData>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x828,%rsp
lea    0xe78(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1254 <LoadFormData+0xe4>
mov    %rax,%r12
movb   $0x0,(%rsp)
lea    0x420(%rsp),%rdi
mov    $0x3ff,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     1245 <LoadFormData+0xd5>
lea    0x22(%rsp),%r14
lea    0xe3c(%rip),%r15
lea    0x420(%rsp),%rbx
lea    0x20(%rsp),%r13
mov    %rsp,%rbp
jmp    1200 <LoadFormData+0x90>
nopl   0x0(%rax)
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1070 <AppendFormData@plt>
mov    %rbx,%rdi
mov    $0x3ff,%esi
mov    %r12,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     1245 <LoadFormData+0xd5>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r13,%rdx
call   1080 <sscanf@plt>
cmp    $0x1,%eax
jne    11e0 <LoadFormData+0x70>
mov    %r13,%rdi
call   1050 <strlen@plt>
cmp    $0x2,%eax
jl     11e0 <LoadFormData+0x70>
cmpb   $0x25,0x20(%rsp)
jne    11e0 <LoadFormData+0x70>
cmpb   $0x25,0x21(%rsp)
jne    11e0 <LoadFormData+0x70>
mov    %rbp,%rdi
mov    %r14,%rsi
mov    $0x14,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x14(%rsp)
jmp    11eb <LoadFormData+0x7b>
mov    %r12,%rdi
call   1040 <fclose@plt>
mov    $0x1,%eax
jmp    1256 <LoadFormData+0xe6>
xor    %eax,%eax
add    $0x828,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rt\00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @LoadFormData(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [1024 x i8]
%5 = alloca [1024 x i8]
%6 = alloca i32*
%7 = alloca [21 x i8]
store i8* %0, i8** %3
%8 = load i8*, i8** %3
%9 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %9, i32** %6
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %12
11: ; preds = %1
store i32 0, i32* %2
br label %57
12: ; preds = %1
%13 = getelementptr inbounds [21 x i8], [21 x i8]* %7, i64 0, i64 0
store i8 0, i8* %13
br label %14
14: ; preds = %53, %12
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%16 = load i32*, i32** %6
%17 = call i64 @fgets(i8* %15, i32 1023, i32* %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %54
19: ; preds = %14
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%22 = call i32 @sscanf(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %21)
%23 = icmp eq i32 %22, 1
br i1 %23, label %24, label %49
24: ; preds = %19
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%26 = call i32 @strlen(i8* %25)
%27 = icmp sge i32 %26, 2
br i1 %27, label %28, label %44
28: ; preds = %24
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 37
br i1 %32, label %33, label %44
33: ; preds = %28
%34 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 1
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 37
br i1 %37, label %38, label %44
38: ; preds = %33
%39 = getelementptr inbounds [21 x i8], [21 x i8]* %7, i64 0, i64 0
%40 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%41 = getelementptr inbounds i8, i8* %40, i64 2
%42 = call i32 @strncpy(i8* %39, i8* %41, i32 20)
%43 = getelementptr inbounds [21 x i8], [21 x i8]* %7, i64 0, i64 20
store i8 0, i8* %43
br label %48
44: ; preds = %33, %28, %24
%45 = getelementptr inbounds [21 x i8], [21 x i8]* %7, i64 0, i64 0
%46 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%47 = call i32 @AppendFormData(i8* %45, i8* %46)
br label %48
48: ; preds = %44, %38
br label %53
49: ; preds = %19
%50 = getelementptr inbounds [21 x i8], [21 x i8]* %7, i64 0, i64 0
%51 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%52 = call i32 @AppendFormData(i8* %50, i8* %51)
br label %53
53: ; preds = %49, %48
br label %14
54: ; preds = %14
%55 = load i32*, i32** %6
%56 = call i32 @fclose(i32* %55)
store i32 1, i32* %2
br label %57
57: ; preds = %54, %11
%58 = load i32, i32* %2
ret i32 %58
}

LLVM IR (-O2):
@.str = [3 x i8] c"rt\00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @LoadFormData(i8* nocapture %0) {
%2 = alloca [1024 x i8]
%3 = alloca [1024 x i8]
%4 = alloca [21 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [21 x i8], [21 x i8]* %4, i64 0, i64 0
%8 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %40, label %10
10: ; preds = %1
store i8 0, i8* %7
%11 = call i64 @fgets(i8* %5, i32 1023, i32* %8)
%12 = icmp eq i64 %11, 0
br i1 %12, label %38, label %13
13: ; preds = %10
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 1
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 2
%16 = getelementptr inbounds [21 x i8], [21 x i8]* %4, i64 0, i64 20
br label %17
17: ; preds = %13, %35
%18 = call i32 @sscanf(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %33
20: ; preds = %17
%21 = call i32 @strlen(i8* %6)
%22 = icmp sgt i32 %21, 1
%23 = load i8, i8* %6
%24 = icmp eq i8 %23, 37
%25 = select i1 %22, i1 %24, i1 false
%26 = load i8, i8* %14
%27 = icmp eq i8 %26, 37
%28 = select i1 %25, i1 %27, i1 false
br i1 %28, label %29, label %31
29: ; preds = %20
%30 = call i32 @strncpy(i8* %7, i8* %15, i32 20)
store i8 0, i8* %16
br label %35
31: ; preds = %20
%32 = call i32 @AppendFormData(i8* %7, i8* %5)
br label %35
33: ; preds = %17
%34 = call i32 @AppendFormData(i8* %7, i8* %5)
br label %35
35: ; preds = %29, %31, %33
%36 = call i64 @fgets(i8* %5, i32 1023, i32* %8)
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %17
38: ; preds = %35, %10
%39 = call i32 @fclose(i32* %8)
br label %40
40: ; preds = %1, %38
%41 = phi i32 [ 1, %38 ], [ 0, %1 ]
ret i32 %41
}