#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*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sscanf(char *, char *, int *);
scalar_t__ strncmp(char *, char *, int);
int main(int argc, char *argv[]) {
  FILE *fp;
  char linebuf[1024];
  int group_count = 0;
  int group, base;
  int i;
  if (argc < 2) {
    printf("parameter 1: DoorGroup.txt\n");
    return 0;
  }
  fp = fopen(argv[1], "r");
  while (fgets(linebuf, 1024, fp) != NULL) {
    if (strncmp(linebuf, "DoorGroup", 9)) {
      sscanf(linebuf, "%d", &base);
      for (i = 0; i < 10; i++) {
        if (*(linebuf + 4 + i * 2) == 'Y') {
          printf("INSERT INTO door_group (id,door) VALUES (%d,%d);\n", group,
                 base + i);
        }
      }
    } else {
      sscanf(linebuf + 10, "%d", &group);
      group_count++;
    }
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x424(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11a7 <main+0x47>
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12cd <main+0x16d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe66(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
lea    -0x420(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x400,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     12bd <main+0x15d>
lea    -0x420(%rbp),%rdi
lea    0xe32(%rip),%rsi
mov    $0x9,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     128b <main+0x12b>
lea    -0x420(%rbp),%rdi
lea    0xe1a(%rip),%rsi
lea    -0x42c(%rbp),%rdx
call   1070 <sscanf@plt>
movl   $0x0,-0x430(%rbp)
cmpl   $0xa,-0x430(%rbp)
jge    1286 <main+0x126>
mov    -0x430(%rbp),%eax
shl    $0x1,%eax
cltq
movsbl -0x41c(%rbp,%rax,1),%eax
ff
cmp    $0x59,%eax
jne    126d <main+0x10d>
mov    -0x428(%rbp),%esi
mov    -0x42c(%rbp),%edx
add    -0x430(%rbp),%edx
lea    0xdc5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1272 <main+0x112>
mov    -0x430(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x430(%rbp)
jmp    1224 <main+0xc4>
jmp    12b8 <main+0x158>
lea    -0x420(%rbp),%rdi
add    $0xa,%rdi
lea    0xd8b(%rip),%rsi
lea    -0x428(%rbp),%rdx
call   1070 <sscanf@plt>
mov    -0x424(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x424(%rbp)
jmp    11bf <main+0x5f>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
cmp    $0x1,%edi
jg     1197 <main+0x27>
lea    0xeb4(%rip),%rdi
call   1040 <puts@plt>
jmp    140f <main+0x29f>
mov    0x8(%rsi),%rdi
lea    0xe5e(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r12
lea    0x10(%rsp),%rdi
mov    $0x400,%esi
mov    %rax,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     1407 <main+0x297>
lea    0xe36(%rip),%r15
lea    0x10(%rsp),%rbx
lea    0xe34(%rip),%r13
lea    0x8(%rsp),%r14
lea    0xe2b(%rip),%rbp
jmp    1209 <main+0x99>
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %r12,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     1407 <main+0x297>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x9,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     12b0 <main+0x140>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %r14,%rdx
call   1080 <sscanf@plt>
cmpb   $0x59,0x14(%rsp)
je     12d0 <main+0x160>
cmpb   $0x59,0x16(%rsp)
je     12ed <main+0x17d>
cmpb   $0x59,0x18(%rsp)
je     130d <main+0x19d>
cmpb   $0x59,0x1a(%rsp)
je     132d <main+0x1bd>
cmpb   $0x59,0x1c(%rsp)
je     134d <main+0x1dd>
cmpb   $0x59,0x1e(%rsp)
je     136d <main+0x1fd>
cmpb   $0x59,0x20(%rsp)
je     138d <main+0x21d>
cmpb   $0x59,0x22(%rsp)
je     13ad <main+0x23d>
cmpb   $0x59,0x24(%rsp)
je     13cd <main+0x25d>
cmpb   $0x59,0x26(%rsp)
jne    11f0 <main+0x80>
jmp    13ed <main+0x27d>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0x1a(%rsp),%rdi
mov    %r13,%rsi
lea    0xc(%rsp),%rdx
call   1080 <sscanf@plt>
jmp    11f0 <main+0x80>
nopw   0x0(%rax,%rax,1)
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
cmpb   $0x59,0x16(%rsp)
jne    1246 <main+0xd6>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
add    $0x1,%edx
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
cmpb   $0x59,0x18(%rsp)
jne    1251 <main+0xe1>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
add    $0x2,%edx
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
cmpb   $0x59,0x1a(%rsp)
jne    125c <main+0xec>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
add    $0x3,%edx
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
cmpb   $0x59,0x1c(%rsp)
jne    1267 <main+0xf7>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
add    $0x4,%edx
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
cmpb   $0x59,0x1e(%rsp)
jne    1272 <main+0x102>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
add    $0x5,%edx
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
cmpb   $0x59,0x20(%rsp)
jne    127d <main+0x10d>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
add    $0x6,%edx
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
cmpb   $0x59,0x22(%rsp)
jne    1288 <main+0x118>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
add    $0x7,%edx
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
cmpb   $0x59,0x24(%rsp)
jne    1293 <main+0x123>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
add    $0x8,%edx
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
cmpb   $0x59,0x26(%rsp)
jne    11f0 <main+0x80>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
add    $0x9,%edx
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    11f0 <main+0x80>
mov    %r12,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"parameter 1: DoorGroup.txt\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [10 x i8] c"DoorGroup\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [50 x i8] c"INSERT INTO door_group (id,door) VALUES (%d,%d);\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [1024 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 2
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %67
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %20, i32** %6
br label %21
21: ; preds = %63, %16
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%23 = load i32*, i32** %6
%24 = call i32* @fgets(i8* %22, i32 1024, i32* %23)
%25 = icmp ne i32* %24, null
br i1 %25, label %26, label %64
26: ; preds = %21
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%28 = call i64 @strncmp(i8* %27, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 9)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %57
30: ; preds = %26
%31 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%32 = call i32 @sscanf(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %10)
store i32 0, i32* %11
br label %33
33: ; preds = %53, %30
%34 = load i32, i32* %11
%35 = icmp slt i32 %34, 10
br i1 %35, label %36, label %56
36: ; preds = %33
%37 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%38 = getelementptr inbounds i8, i8* %37, i64 4
%39 = load i32, i32* %11
%40 = mul nsw i32 %39, 2
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %38, i64 %41
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 89
br i1 %45, label %46, label %52
46: ; preds = %36
%47 = load i32, i32* %9
%48 = load i32, i32* %10
%49 = load i32, i32* %11
%50 = add nsw i32 %48, %49
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0), i32 %47, i32 %50)
br label %52
52: ; preds = %46, %36
br label %53
53: ; preds = %52
%54 = load i32, i32* %11
%55 = add nsw i32 %54, 1
store i32 %55, i32* %11
br label %33
56: ; preds = %33
br label %63
57: ; preds = %26
%58 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%59 = getelementptr inbounds i8, i8* %58, i64 10
%60 = call i32 @sscanf(i8* %59, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %9)
%61 = load i32, i32* %8
%62 = add nsw i32 %61, 1
store i32 %62, i32* %8
br label %63
63: ; preds = %57, %56
br label %21
64: ; preds = %21
%65 = load i32*, i32** %6
%66 = call i32 @fclose(i32* %65)
store i32 0, i32* %3
br label %67
67: ; preds = %64, %14
%68 = load i32, i32* %3
ret i32 %68
}

LLVM IR (-O2):
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [10 x i8] c"DoorGroup\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [50 x i8] c"INSERT INTO door_group (id,door) VALUES (%d,%d);\0A\00"
@str = [27 x i8] c"parameter 1: DoorGroup.txt\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = icmp slt i32 %0, 2
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
br label %120
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32* @fgets(i8* %6, i32 1024, i32* %15)
%17 = icmp eq i32* %16, null
br i1 %17, label %118, label %18
18: ; preds = %12
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 4
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 10
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 6
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 8
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 10
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 12
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 14
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 16
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 18
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 20
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 22
br label %30
30: ; preds = %18, %115
%31 = call i64 @strncmp(i8* %6, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 9)
%32 = icmp eq i64 %31, 0
br i1 %32, label %113, label %33
33: ; preds = %30
%34 = call i32 @sscanf(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %5)
%35 = load i8, i8* %19
%36 = icmp eq i8 %35, 89
br i1 %36, label %37, label %41
37: ; preds = %33
%38 = load i32, i32* %4
%39 = load i32, i32* %5
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0), i32 %38, i32 %39)
br label %41
41: ; preds = %33, %37
%42 = load i8, i8* %21
%43 = icmp eq i8 %42, 89
br i1 %43, label %44, label %49
44: ; preds = %41
%45 = load i32, i32* %4
%46 = load i32, i32* %5
%47 = add nsw i32 %46, 1
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0), i32 %45, i32 %47)
br label %49
49: ; preds = %44, %41
%50 = load i8, i8* %22
%51 = icmp eq i8 %50, 89
br i1 %51, label %52, label %57
52: ; preds = %49
%53 = load i32, i32* %4
%54 = load i32, i32* %5
%55 = add nsw i32 %54, 2
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0), i32 %53, i32 %55)
br label %57
57: ; preds = %52, %49
%58 = load i8, i8* %23
%59 = icmp eq i8 %58, 89
br i1 %59, label %60, label %65
60: ; preds = %57
%61 = load i32, i32* %4
%62 = load i32, i32* %5
%63 = add nsw i32 %62, 3
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0), i32 %61, i32 %63)
br label %65
65: ; preds = %60, %57
%66 = load i8, i8* %24
%67 = icmp eq i8 %66, 89
br i1 %67, label %68, label %73
68: ; preds = %65
%69 = load i32, i32* %4
%70 = load i32, i32* %5
%71 = add nsw i32 %70, 4
%72 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0), i32 %69, i32 %71)
br label %73
73: ; preds = %68, %65
%74 = load i8, i8* %25
%75 = icmp eq i8 %74, 89
br i1 %75, label %76, label %81
76: ; preds = %73
%77 = load i32, i32* %4
%78 = load i32, i32* %5
%79 = add nsw i32 %78, 5
%80 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0), i32 %77, i32 %79)
br label %81
81: ; preds = %76, %73
%82 = load i8, i8* %26
%83 = icmp eq i8 %82, 89
br i1 %83, label %84, label %89
84: ; preds = %81
%85 = load i32, i32* %4
%86 = load i32, i32* %5
%87 = add nsw i32 %86, 6
%88 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0), i32 %85, i32 %87)
br label %89
89: ; preds = %84, %81
%90 = load i8, i8* %27
%91 = icmp eq i8 %90, 89
br i1 %91, label %92, label %97
92: ; preds = %89
%93 = load i32, i32* %4
%94 = load i32, i32* %5
%95 = add nsw i32 %94, 7
%96 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0), i32 %93, i32 %95)
br label %97
97: ; preds = %92, %89
%98 = load i8, i8* %28
%99 = icmp eq i8 %98, 89
br i1 %99, label %100, label %105
100: ; preds = %97
%101 = load i32, i32* %4
%102 = load i32, i32* %5
%103 = add nsw i32 %102, 8
%104 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0), i32 %101, i32 %103)
br label %105
105: ; preds = %100, %97
%106 = load i8, i8* %29
%107 = icmp eq i8 %106, 89
br i1 %107, label %108, label %115
108: ; preds = %105
%109 = load i32, i32* %4
%110 = load i32, i32* %5
%111 = add nsw i32 %110, 9
%112 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0), i32 %109, i32 %111)
br label %115
113: ; preds = %30
%114 = call i32 @sscanf(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %4)
br label %115
115: ; preds = %105, %108, %113
%116 = call i32* @fgets(i8* %6, i32 1024, i32* %15)
%117 = icmp eq i32* %116, null
br i1 %117, label %118, label %30
118: ; preds = %115, %12
%119 = call i32 @fclose(i32* %15)
br label %120
120: ; preds = %118, %10
ret i32 0
}