#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*/ line;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ pq(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
char *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int main(void) {
  char line[1024], *c, *bra, manuf[8];
  int manufs = 0;
  int mode = 0;
  int lino = 0;
  int manuf_len = 0;
  FILE *devf;
  devf = fopen("devlist.h", "w");
  if (!devf) {
    fprintf(stderr, "Cannot create output file!\n");
    return 1;
  }
  while (fgets(line, sizeof(line) - 1, stdin)) {
    lino++;
    if ((c = strchr(line, '\n')))
      *c = 0;
    if (!line[0] || line[0] == '#')
      continue;
    if (line[0] == '\t') {
      switch (mode) {
      case 1:
        if (strlen(line) > 5 && line[5] == ' ') {
          c = line + 5;
          while (*c == ' ')
            *c++ = 0;
          if (manuf_len + strlen(c) + 1 > 63) {
            bra = strchr(c, '[');
            if (bra && bra > c && bra[-1] == ' ')
              bra[-1] = 0;
            if (manuf_len + strlen(c) + 1 > 63) {
              fprintf(stderr, "Line %d: Product name too long\n", lino);
              return 1;
            }
          }
          fprintf(devf, "\tPRODUCT(%s,%s,\"", manuf, line + 1);
          pq(devf, c);
          fputs("\")\n", devf);
        } else
          goto err;
        break;
      default:
        goto err;
      }
    } else if (strlen(line) > 4 && line[4] == ' ') {
      c = line + 4;
      while (*c == ' ')
        *c++ = 0;
      if (manufs)
        fputs("ENDMANUF()\n\n", devf);
      manufs++;
      strcpy(manuf, line);
      manuf_len = strlen(c);
      if (manuf_len + 24 > 63) {
        fprintf(stderr, "Line %d: manufacturer name too long\n", lino);
        return 1;
      }
      fprintf(devf, "MANUF(%s,\"", manuf);
      pq(devf, c);
      fputs("\")\n", devf);
      mode = 1;
    } else {
    err:
      fprintf(stderr, "Line %d: Syntax error in mode %d: %s\n", lino, mode,
              line);
      return 1;
    }
  }
  fputs("ENDMANUF()\n\n#undef MANUF\n#undef PRODUCT\n#undef ENDMANUF\n", devf);
  fclose(devf);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x42c(%rbp)
movl   $0x0,-0x430(%rbp)
movl   $0x0,-0x434(%rbp)
movl   $0x0,-0x438(%rbp)
lea    0xe2f(%rip),%rdi
lea    0xe32(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x440(%rbp)
cmpq   $0x0,-0x440(%rbp)
jne    1215 <main+0x85>
mov    0x2ddf(%rip),%rax
mov    (%rax),%edi
lea    0xe0a(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1625 <main+0x495>
jmp    121a <main+0x8a>
lea    -0x410(%rbp),%rdi
mov    0x2dc0(%rip),%rax
mov    (%rax),%edx
mov    $0x3ff,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     15ff <main+0x46f>
mov    -0x434(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x434(%rbp)
lea    -0x410(%rbp),%rdi
mov    $0xa,%esi
call   1060 <strchr@plt>
mov    %rax,-0x418(%rbp)
cmp    $0x0,%rax
je     1279 <main+0xe9>
mov    -0x418(%rbp),%rax
movb   $0x0,(%rax)
cmpb   $0x0,-0x410(%rbp)
je     1296 <main+0x106>
movsbl -0x410(%rbp),%eax
cmp    $0x23,%eax
jne    129b <main+0x10b>
jmp    121a <main+0x8a>
movsbl -0x410(%rbp),%eax
cmp    $0x9,%eax
jne    1471 <main+0x2e1>
mov    -0x430(%rbp),%eax
sub    $0x1,%eax
jne    1467 <main+0x2d7>
jmp    12bf <main+0x12f>
lea    -0x410(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x5,%eax
jle    145d <main+0x2cd>
movsbl -0x40b(%rbp),%eax
cmp    $0x20,%eax
jne    145d <main+0x2cd>
lea    -0x410(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0x418(%rbp)
mov    -0x418(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    1326 <main+0x196>
mov    -0x418(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x418(%rbp)
movb   $0x0,(%rax)
jmp    12f6 <main+0x166>
mov    -0x438(%rbp),%eax
mov    %eax,-0x444(%rbp)
mov    -0x418(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x444(%rbp),%eax
add    %ecx,%eax
add    $0x1,%eax
cmp    $0x3f,%eax
jle    1409 <main+0x279>
mov    -0x418(%rbp),%rdi
mov    $0x5b,%esi
call   1060 <strchr@plt>
mov    %rax,-0x420(%rbp)
cmpq   $0x0,-0x420(%rbp)
je     13ad <main+0x21d>
mov    -0x420(%rbp),%rax
cmp    -0x418(%rbp),%rax
jbe    13ad <main+0x21d>
mov    -0x420(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x20,%eax
jne    13ad <main+0x21d>
mov    -0x420(%rbp),%rax
movb   $0x0,-0x1(%rax)
mov    -0x438(%rbp),%eax
mov    %eax,-0x448(%rbp)
mov    -0x418(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x448(%rbp),%eax
add    %ecx,%eax
add    $0x1,%eax
cmp    $0x3f,%eax
jle    1404 <main+0x274>
mov    0x2bf6(%rip),%rax
mov    (%rax),%edi
mov    -0x434(%rbp),%edx
lea    0xc37(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1625 <main+0x495>
jmp    1409 <main+0x279>
mov    -0x440(%rbp),%rax
mov    %eax,%edi
lea    -0x428(%rbp),%rdx
lea    -0x410(%rbp),%rcx
add    $0x1,%rcx
lea    0xc1d(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x440(%rbp),%rdi
mov    -0x418(%rbp),%rsi
call   10b0 <pq@plt>
mov    -0x440(%rbp),%rsi
lea    0xc06(%rip),%rdi
call   1070 <fputs@plt>
jmp    1462 <main+0x2d2>
jmp    15bf <main+0x42f>
jmp    146c <main+0x2dc>
jmp    15bf <main+0x42f>
jmp    15fa <main+0x46a>
lea    -0x410(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x4,%eax
jle    15ba <main+0x42a>
movsbl -0x40c(%rbp),%eax
cmp    $0x20,%eax
jne    15ba <main+0x42a>
lea    -0x410(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x418(%rbp)
mov    -0x418(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    14d8 <main+0x348>
mov    -0x418(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x418(%rbp)
movb   $0x0,(%rax)
jmp    14a8 <main+0x318>
cmpl   $0x0,-0x42c(%rbp)
je     14f8 <main+0x368>
mov    -0x440(%rbp),%rsi
lea    0xb6a(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x42c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x42c(%rbp)
lea    -0x428(%rbp),%rdi
lea    -0x410(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x418(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x438(%rbp)
mov    -0x438(%rbp),%eax
add    $0x18,%eax
cmp    $0x3f,%eax
jle    1567 <main+0x3d7>
mov    0x2a93(%rip),%rax
mov    (%rax),%edi
mov    -0x434(%rbp),%edx
lea    0xb16(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1625 <main+0x495>
mov    -0x440(%rbp),%rax
mov    %eax,%edi
lea    -0x428(%rbp),%rdx
lea    0xb11(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x440(%rbp),%rdi
mov    -0x418(%rbp),%rsi
call   10b0 <pq@plt>
mov    -0x440(%rbp),%rsi
lea    0xab3(%rip),%rdi
call   1070 <fputs@plt>
movl   $0x1,-0x430(%rbp)
jmp    15f5 <main+0x465>
jmp    15bf <main+0x42f>
mov    0x2a12(%rip),%rax
mov    (%rax),%edi
mov    -0x434(%rbp),%edx
mov    -0x430(%rbp),%ecx
lea    -0x410(%rbp),%r8
lea    0xab8(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1625 <main+0x495>
jmp    15fa <main+0x46a>
jmp    121a <main+0x8a>
mov    -0x440(%rbp),%rsi
lea    0xab3(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x440(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
lea    0xe58(%rip),%rdi
lea    0xe5b(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1407 <main+0x277>
mov    %rax,%r15
mov    0x2e21(%rip),%r13
mov    0x0(%r13),%edx
lea    0x10(%rsp),%rdi
mov    $0x3ff,%esi
call   1070 <fgets@plt>
test   %rax,%rax
je     13e2 <main+0x252>
lea    0x10(%rsp),%rbx
movl   $0x0,(%rsp)
xor    %ebp,%ebp
xor    %r12d,%r12d
xor    %r14d,%r14d
movl   $0x0,0x4(%rsp)
add    $0x1,%ebp
jmp    122d <main+0x9d>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x0(%r13),%edx
mov    %rbx,%rdi
mov    $0x3ff,%esi
call   1070 <fgets@plt>
add    $0x1,%ebp
test   %rax,%rax
je     13e2 <main+0x252>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     1242 <main+0xb2>
movb   $0x0,(%rax)
mov    0x10(%rsp),%al
test   %al,%al
je     1210 <main+0x80>
cmp    $0x23,%al
je     1210 <main+0x80>
cmp    $0x9,%al
jne    12fd <main+0x16d>
test   $0x1,%r12b
lea    0x8(%rsp),%r12
je     1435 <main+0x2a5>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cmp    $0x6,%eax
jl     1435 <main+0x2a5>
cmpb   $0x20,0x15(%rsp)
jne    1435 <main+0x2a5>
lea    0x15(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
movb   $0x0,(%r14)
cmpb   $0x20,0x1(%r14)
lea    0x1(%r14),%r14
je     1290 <main+0x100>
mov    %r14,%rdi
call   1050 <strlen@plt>
add    (%rsp),%eax
cmp    $0x3f,%eax
jl     12df <main+0x14f>
mov    %r14,%rdi
mov    $0x5b,%esi
call   1060 <strchr@plt>
cmp    %r14,%rax
jbe    12cb <main+0x13b>
cmpb   $0x20,-0x1(%rax)
jne    12cb <main+0x13b>
movb   $0x0,-0x1(%rax)
mov    %r14,%rdi
call   1050 <strlen@plt>
add    (%rsp),%eax
cmp    $0x3f,%eax
jge    146a <main+0x2da>
mov    %r15d,%edi
lea    0xd5f(%rip),%rsi
mov    %r12,%rdx
lea    0x11(%rsp),%rcx
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    1397 <main+0x207>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cmp    $0x5,%eax
lea    0x8(%rsp),%r12
jl     1435 <main+0x2a5>
cmpb   $0x20,0x14(%rsp)
jne    1435 <main+0x2a5>
lea    0x14(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movb   $0x0,(%r14)
cmpb   $0x20,0x1(%r14)
lea    0x1(%r14),%r14
je     1330 <main+0x1a0>
cmpl   $0x0,0x4(%rsp)
je     135f <main+0x1cf>
mov    $0xc,%esi
mov    $0x1,%edx
lea    0xd06(%rip),%rdi
mov    %r15,%rcx
call   10b0 <fwrite@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %eax,(%rsp)
cmp    $0x28,%eax
jge    1458 <main+0x2c8>
addl   $0x1,0x4(%rsp)
mov    %r15d,%edi
lea    0xd02(%rip),%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   10a0 <pq@plt>
mov    $0x3,%esi
mov    $0x1,%edx
lea    0xca6(%rip),%rdi
mov    %r15,%rcx
call   10b0 <fwrite@plt>
mov    0x0(%r13),%edx
mov    %rbx,%rdi
mov    $0x3ff,%esi
call   1070 <fgets@plt>
mov    $0x1,%r14d
mov    $0x1,%r12b
test   %rax,%rax
je     13e2 <main+0x252>
add    $0x1,%ebp
jmp    122d <main+0x9d>
lea    0xcd7(%rip),%rdi
mov    $0x38,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   10b0 <fwrite@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
jmp    1423 <main+0x293>
mov    0x2bca(%rip),%rax
mov    (%rax),%edi
lea    0xbf5(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2b9c(%rip),%rax
mov    (%rax),%edi
lea    0xc55(%rip),%rsi
lea    0x10(%rsp),%r8
mov    %ebp,%edx
mov    %r14d,%ecx
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    141e <main+0x28e>
mov    0x2b79(%rip),%rax
mov    (%rax),%edi
lea    0xc02(%rip),%rsi
jmp    147a <main+0x2ea>
mov    0x2b67(%rip),%rax
mov    (%rax),%edi
lea    0xbae(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    141e <main+0x28e>

LLVM IR (-O0):
@.str = [10 x i8] c"devlist.h\00"
@.str.1 = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.2 = [28 x i8] c"Cannot create output file!\0A\00"
@stdin = global i32 0
@.str.3 = [32 x i8] c"Line %d: Product name too long\0A\00"
@.str.4 = [17 x i8] c"\09PRODUCT(%s,%s,\22\00"
@.str.5 = [4 x i8] c"\22)\0A\00"
@.str.6 = [13 x i8] c"ENDMANUF()\0A\0A\00"
@.str.7 = [37 x i8] c"Line %d: manufacturer name too long\0A\00"
@.str.8 = [11 x i8] c"MANUF(%s,\22\00"
@.str.9 = [38 x i8] c"Line %d: Syntax error in mode %d: %s\0A\00"
@.str.10 = [57 x i8] c"ENDMANUF()\0A\0A#undef MANUF\0A#undef PRODUCT\0A#undef ENDMANUF\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1024 x i8]
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [8 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
store i32 0, i32* %1
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
%11 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %11, i32** %10
%12 = load i32*, i32** %10
%13 = icmp ne i32* %12, null
br i1 %13, label %17, label %14
14: ; preds = %0
%15 = load i32, i32* @stderr
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %186
17: ; preds = %0
br label %18
18: ; preds = %180, %40, %17
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%20 = load i32, i32* @stdin
%21 = call i64 @fgets(i8* %19, i32 1023, i32 %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %181
23: ; preds = %18
%24 = load i32, i32* %8
%25 = add nsw i32 %24, 1
store i32 %25, i32* %8
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%27 = call i8* @strchr(i8* %26, i8 signext 10)
store i8* %27, i8** %3
%28 = icmp ne i8* %27, null
br i1 %28, label %29, label %31
29: ; preds = %23
%30 = load i8*, i8** %3
store i8 0, i8* %30
br label %31
31: ; preds = %29, %23
%32 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%33 = load i8, i8* %32
%34 = icmp ne i8 %33, 0
br i1 %34, label %35, label %40
35: ; preds = %31
%36 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 35
br i1 %39, label %40, label %41
40: ; preds = %35, %31
br label %18
41: ; preds = %35
%42 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 9
br i1 %45, label %46, label %121
46: ; preds = %41
%47 = load i32, i32* %7
switch i32 %47, label %119 [
i32 1, label %48
]
48: ; preds = %46
%49 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%50 = call i32 @strlen(i8* %49)
%51 = icmp sgt i32 %50, 5
br i1 %51, label %52, label %117
52: ; preds = %48
%53 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 5
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = icmp eq i32 %55, 32
br i1 %56, label %57, label %117
57: ; preds = %52
%58 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%59 = getelementptr inbounds i8, i8* %58, i64 5
store i8* %59, i8** %3
br label %60
60: ; preds = %65, %57
%61 = load i8*, i8** %3
%62 = load i8, i8* %61
%63 = sext i8 %62 to i32
%64 = icmp eq i32 %63, 32
br i1 %64, label %65, label %68
65: ; preds = %60
%66 = load i8*, i8** %3
%67 = getelementptr inbounds i8, i8* %66, i32 1
store i8* %67, i8** %3
store i8 0, i8* %66
br label %60
68: ; preds = %60
%69 = load i32, i32* %9
%70 = load i8*, i8** %3
%71 = call i32 @strlen(i8* %70)
%72 = add nsw i32 %69, %71
%73 = add nsw i32 %72, 1
%74 = icmp sgt i32 %73, 63
br i1 %74, label %75, label %105
75: ; preds = %68
%76 = load i8*, i8** %3
%77 = call i8* @strchr(i8* %76, i8 signext 91)
store i8* %77, i8** %4
%78 = load i8*, i8** %4
%79 = icmp ne i8* %78, null
br i1 %79, label %80, label %93
80: ; preds = %75
%81 = load i8*, i8** %4
%82 = load i8*, i8** %3
%83 = icmp ugt i8* %81, %82
br i1 %83, label %84, label %93
84: ; preds = %80
%85 = load i8*, i8** %4
%86 = getelementptr inbounds i8, i8* %85, i64 -1
%87 = load i8, i8* %86
%88 = sext i8 %87 to i32
%89 = icmp eq i32 %88, 32
br i1 %89, label %90, label %93
90: ; preds = %84
%91 = load i8*, i8** %4
%92 = getelementptr inbounds i8, i8* %91, i64 -1
store i8 0, i8* %92
br label %93
93: ; preds = %90, %84, %80, %75
%94 = load i32, i32* %9
%95 = load i8*, i8** %3
%96 = call i32 @strlen(i8* %95)
%97 = add nsw i32 %94, %96
%98 = add nsw i32 %97, 1
%99 = icmp sgt i32 %98, 63
br i1 %99, label %100, label %104
100: ; preds = %93
%101 = load i32, i32* @stderr
%102 = load i32, i32* %8
%103 = call i32 (i32, i8*, ...) @fprintf(i32 %101, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %102)
store i32 1, i32* %1
br label %186
104: ; preds = %93
br label %105
105: ; preds = %104, %68
%106 = load i32*, i32** %10
%107 = ptrtoint i32* %106 to i32
%108 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%109 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%110 = getelementptr inbounds i8, i8* %109, i64 1
%111 = call i32 (i32, i8*, ...) @fprintf(i32 %107, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %108, i8* %110)
%112 = load i32*, i32** %10
%113 = load i8*, i8** %3
%114 = call i32 @pq(i32* %112, i8* %113)
%115 = load i32*, i32** %10
%116 = call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32* %115)
br label %118
117: ; preds = %52, %48
br label %173
118: ; preds = %105
br label %120
119: ; preds = %46
br label %173
120: ; preds = %118
br label %180
121: ; preds = %41
%122 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%123 = call i32 @strlen(i8* %122)
%124 = icmp sgt i32 %123, 4
br i1 %124, label %125, label %172
125: ; preds = %121
%126 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 4
%127 = load i8, i8* %126
%128 = sext i8 %127 to i32
%129 = icmp eq i32 %128, 32
br i1 %129, label %130, label %172
130: ; preds = %125
%131 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%132 = getelementptr inbounds i8, i8* %131, i64 4
store i8* %132, i8** %3
br label %133
133: ; preds = %138, %130
%134 = load i8*, i8** %3
%135 = load i8, i8* %134
%136 = sext i8 %135 to i32
%137 = icmp eq i32 %136, 32
br i1 %137, label %138, label %141
138: ; preds = %133
%139 = load i8*, i8** %3
%140 = getelementptr inbounds i8, i8* %139, i32 1
store i8* %140, i8** %3
store i8 0, i8* %139
br label %133
141: ; preds = %133
%142 = load i32, i32* %6
%143 = icmp ne i32 %142, 0
br i1 %143, label %144, label %147
144: ; preds = %141
%145 = load i32*, i32** %10
%146 = call i32 @fputs(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32* %145)
br label %147
147: ; preds = %144, %141
%148 = load i32, i32* %6
%149 = add nsw i32 %148, 1
store i32 %149, i32* %6
%150 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%151 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%152 = call i32 @strcpy(i8* %150, i8* %151)
%153 = load i8*, i8** %3
%154 = call i32 @strlen(i8* %153)
store i32 %154, i32* %9
%155 = load i32, i32* %9
%156 = add nsw i32 %155, 24
%157 = icmp sgt i32 %156, 63
br i1 %157, label %158, label %162
158: ; preds = %147
%159 = load i32, i32* @stderr
%160 = load i32, i32* %8
%161 = call i32 (i32, i8*, ...) @fprintf(i32 %159, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i32 %160)
store i32 1, i32* %1
br label %186
162: ; preds = %147
%163 = load i32*, i32** %10
%164 = ptrtoint i32* %163 to i32
%165 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%166 = call i32 (i32, i8*, ...) @fprintf(i32 %164, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i8* %165)
%167 = load i32*, i32** %10
%168 = load i8*, i8** %3
%169 = call i32 @pq(i32* %167, i8* %168)
%170 = load i32*, i32** %10
%171 = call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32* %170)
store i32 1, i32* %7
br label %179
172: ; preds = %125, %121
br label %173
173: ; preds = %172, %119, %117
%174 = load i32, i32* @stderr
%175 = load i32, i32* %8
%176 = load i32, i32* %7
%177 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%178 = call i32 (i32, i8*, ...) @fprintf(i32 %174, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.9, i64 0, i64 0), i32 %175, i32 %176, i8* %177)
store i32 1, i32* %1
br label %186
179: ; preds = %162
br label %180
180: ; preds = %179, %120
br label %18
181: ; preds = %18
%182 = load i32*, i32** %10
%183 = call i32 @fputs(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.10, i64 0, i64 0), i32* %182)
%184 = load i32*, i32** %10
%185 = call i32 @fclose(i32* %184)
store i32 0, i32* %1
br label %186
186: ; preds = %181, %173, %158, %100, %14
%187 = load i32, i32* %1
ret i32 %187
}

LLVM IR (-O2):
@.str = [10 x i8] c"devlist.h\00"
@.str.1 = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.2 = [28 x i8] c"Cannot create output file!\0A\00"
@stdin = global i32 0
@.str.3 = [32 x i8] c"Line %d: Product name too long\0A\00"
@.str.4 = [17 x i8] c"\09PRODUCT(%s,%s,\22\00"
@.str.5 = [4 x i8] c"\22)\0A\00"
@.str.6 = [13 x i8] c"ENDMANUF()\0A\0A\00"
@.str.7 = [37 x i8] c"Line %d: manufacturer name too long\0A\00"
@.str.8 = [11 x i8] c"MANUF(%s,\22\00"
@.str.9 = [38 x i8] c"Line %d: Syntax error in mode %d: %s\0A\00"
@.str.10 = [57 x i8] c"ENDMANUF()\0A\0A#undef MANUF\0A#undef PRODUCT\0A#undef ENDMANUF\0A\00"
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = alloca [8 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %17, label %7
7: ; preds = %0
%8 = load i32, i32* @stdin
%9 = call i64 @fgets(i8* %3, i32 1023, i32 %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %108, label %11
11: ; preds = %7
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 5
%13 = ptrtoint i32* %5 to i64
%14 = trunc i64 %13 to i32
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 1
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 4
br label %102
17: ; preds = %0
%18 = load i32, i32* @stderr
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %111
20: ; preds = %102, %28
%21 = phi i32 [ %104, %102 ], [ %22, %28 ]
%22 = add nsw i32 %21, 1
%23 = call i8* @strchr(i8* %3, i8 signext 10)
%24 = icmp eq i8* %23, null
br i1 %24, label %26, label %25
25: ; preds = %20
store i8 0, i8* %23
br label %26
26: ; preds = %25, %20
%27 = load i8, i8* %3
switch i8 %27, label %65 [
i8 35, label %28
i8 0, label %28
i8 9, label %32
]
28: ; preds = %26, %26
%29 = load i32, i32* @stdin
%30 = call i64 @fgets(i8* %3, i32 1023, i32 %29)
%31 = icmp eq i64 %30, 0
br i1 %31, label %108, label %20
32: ; preds = %26
br i1 %105, label %33, label %90
33: ; preds = %32
%34 = call i32 @strlen(i8* %3)
%35 = icmp sgt i32 %34, 5
%36 = load i8, i8* %12
%37 = icmp eq i8 %36, 32
%38 = select i1 %35, i1 %37, i1 false
br i1 %38, label %39, label %90
39: ; preds = %33, %39
%40 = phi i8* [ %41, %39 ], [ %12, %33 ]
%41 = getelementptr inbounds i8, i8* %40, i64 1
store i8 0, i8* %40
%42 = load i8, i8* %41
%43 = icmp eq i8 %42, 32
br i1 %43, label %39, label %44
44: ; preds = %39
%45 = call i32 @strlen(i8* %41)
%46 = add nsw i32 %45, %103
%47 = icmp sgt i32 %46, 62
br i1 %47, label %48, label %63
48: ; preds = %44
%49 = call i8* @strchr(i8* %41, i8 signext 91)
%50 = icmp ugt i8* %49, %41
br i1 %50, label %51, label %56
51: ; preds = %48
%52 = getelementptr inbounds i8, i8* %49, i64 -1
%53 = load i8, i8* %52
%54 = icmp eq i8 %53, 32
br i1 %54, label %55, label %56
55: ; preds = %51
store i8 0, i8* %52
br label %56
56: ; preds = %55, %51, %48
%57 = call i32 @strlen(i8* %41)
%58 = add nsw i32 %57, %103
%59 = icmp sgt i32 %58, 62
br i1 %59, label %60, label %63
60: ; preds = %56
%61 = load i32, i32* @stderr
%62 = call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %22)
br label %111
63: ; preds = %56, %44
%64 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %4, i8* %15)
br label %93
65: ; preds = %26
%66 = call i32 @strlen(i8* %3)
%67 = icmp sgt i32 %66, 4
%68 = load i8, i8* %16
%69 = icmp eq i8 %68, 32
%70 = select i1 %67, i1 %69, i1 false
br i1 %70, label %71, label %90
71: ; preds = %65, %71
%72 = phi i8* [ %73, %71 ], [ %16, %65 ]
%73 = getelementptr inbounds i8, i8* %72, i64 1
store i8 0, i8* %72
%74 = load i8, i8* %73
%75 = icmp eq i8 %74, 32
br i1 %75, label %71, label %76
76: ; preds = %71
%77 = icmp eq i32 %107, 0
br i1 %77, label %80, label %78
78: ; preds = %76
%79 = call i64 @fwrite(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i64 12, i64 1, i32* %5)
br label %80
80: ; preds = %78, %76
%81 = call i32 @strcpy(i8* %4, i8* %3)
%82 = call i32 @strlen(i8* %73)
%83 = icmp sgt i32 %82, 39
br i1 %83, label %84, label %87
84: ; preds = %80
%85 = load i32, i32* @stderr
%86 = call i32 (i32, i8*, ...) @fprintf(i32 %85, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i32 %22)
br label %111
87: ; preds = %80
%88 = add nsw i32 %107, 1
%89 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i8* %4)
br label %93
90: ; preds = %65, %32, %33
%91 = load i32, i32* @stderr
%92 = call i32 (i32, i8*, ...) @fprintf(i32 %91, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.9, i64 0, i64 0), i32 %22, i32 %106, i8* %3)
br label %111
93: ; preds = %87, %63
%94 = phi i8* [ %73, %87 ], [ %41, %63 ]
%95 = phi i32 [ %88, %87 ], [ %107, %63 ]
%96 = phi i32 [ %82, %87 ], [ %103, %63 ]
%97 = call i32 @pq(i32* %5, i8* %94)
%98 = call i64 @fwrite(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i64 3, i64 1, i32* %5)
%99 = load i32, i32* @stdin
%100 = call i64 @fgets(i8* %3, i32 1023, i32 %99)
%101 = icmp eq i64 %100, 0
br i1 %101, label %108, label %102
102: ; preds = %11, %93
%103 = phi i32 [ 0, %11 ], [ %96, %93 ]
%104 = phi i32 [ 0, %11 ], [ %22, %93 ]
%105 = phi i1 [ false, %11 ], [ true, %93 ]
%106 = phi i32 [ 0, %11 ], [ 1, %93 ]
%107 = phi i32 [ 0, %11 ], [ %95, %93 ]
br label %20
108: ; preds = %93, %28, %7
%109 = call i64 @fwrite(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.10, i64 0, i64 0), i64 56, i64 1, i32* %5)
%110 = call i32 @fclose(i32* %5)
br label %111
111: ; preds = %108, %90, %84, %60, %17
%112 = phi i32 [ 1, %60 ], [ 1, %90 ], [ 1, %84 ], [ 0, %108 ], [ 1, %17 ]
ret i32 %112
}