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

/* Variables and functions */
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *, char *, ...);
char *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *strstr(char *, char *);
int cofile(FILE *infile, FILE *outfile, char *fname, int ppo) {
  char buf[2048];
  char section[200];
  char *pt, *pt2;
  while (fgets(buf, sizeof(buf), infile)) {
    pt = strchr(buf, '\n');
    if (pt != NULL)
      *pt = 0;
    if (!(strchr(buf, '#') == buf)) {
      if (*buf == '[') {
        pt = buf + 1;
        pt2 = strchr(pt, ']');
        if (pt2 != NULL) {
          *pt2 = 0;
          if (strlen(pt) < sizeof(section))
            strcpy(section, pt);
          else
            section[0] = 0;
        }
      } else {
        if (*buf != ';' && strlen(buf) > 2)
          if (strstr(buf, "PORT=") == buf && ppo == 1) {
            pt = strchr(buf, '=');
            pt++;
            fprintf(outfile, "%s.%s.PORT1=%s\n", fname, section, pt);
            fprintf(outfile, "%s.%s.HOST1=*\n", fname, section);
          } else {
            fprintf(outfile, "%s.%s.%s\n", fname, section, buf);
          }
      }
    }
  }
  return 0x0;
}


x86 assembly (clang, -O0):
<cofile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x900,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
lea    -0x820(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x800,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     1379 <cofile+0x219>
lea    -0x820(%rbp),%rdi
mov    $0xa,%esi
call   1050 <strchr@plt>
mov    %rax,-0x8f8(%rbp)
cmpq   $0x0,-0x8f8(%rbp)
je     11c9 <cofile+0x69>
mov    -0x8f8(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x820(%rbp),%rdi
mov    $0x23,%esi
call   1050 <strchr@plt>
lea    -0x820(%rbp),%rcx
cmp    %rcx,%rax
je     1374 <cofile+0x214>
movsbl -0x820(%rbp),%eax
cmp    $0x5b,%eax
jne    127f <cofile+0x11f>
lea    -0x820(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8f8(%rbp)
mov    -0x8f8(%rbp),%rdi
mov    $0x5d,%esi
call   1050 <strchr@plt>
mov    %rax,-0x900(%rbp)
cmpq   $0x0,-0x900(%rbp)
je     127a <cofile+0x11a>
mov    -0x900(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8f8(%rbp),%rdi
call   1040 <strlen@plt>
cltq
cmp    $0xc8,%rax
jae    126e <cofile+0x10e>
lea    -0x8f0(%rbp),%rdi
mov    -0x8f8(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    1275 <cofile+0x115>
movb   $0x0,-0x8f0(%rbp)
jmp    127a <cofile+0x11a>
jmp    136f <cofile+0x20f>
movsbl -0x820(%rbp),%eax
cmp    $0x3b,%eax
je     136a <cofile+0x20a>
lea    -0x820(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x2,%eax
jle    136a <cofile+0x20a>
lea    -0x820(%rbp),%rdi
lea    0xd4e(%rip),%rsi
call   1080 <strstr@plt>
lea    -0x820(%rbp),%rcx
cmp    %rcx,%rax
jne    1341 <cofile+0x1e1>
cmpl   $0x1,-0x1c(%rbp)
jne    1341 <cofile+0x1e1>
lea    -0x820(%rbp),%rdi
mov    $0x3d,%esi
call   1050 <strchr@plt>
mov    %rax,-0x8f8(%rbp)
mov    -0x8f8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8f8(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    -0x8f0(%rbp),%rcx
mov    -0x8f8(%rbp),%r8
lea    0xcee(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    -0x8f0(%rbp),%rcx
lea    0xce1(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    1365 <cofile+0x205>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    -0x8f0(%rbp),%rcx
lea    -0x820(%rbp),%r8
lea    0xcc7(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    136a <cofile+0x20a>
jmp    136f <cofile+0x20f>
jmp    1374 <cofile+0x214>
jmp    117a <cofile+0x1a>
xor    %eax,%eax
add    $0x900,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cofile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x8e8,%rsp
mov    %ecx,%r14d
mov    %rdx,0x8(%rsp)
mov    %rsi,(%rsp)
mov    %rdi,%rbx
lea    0xe0(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x800,%esi
mov    %rbx,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     1308 <cofile+0x1a8>
lea    0xe1(%rsp),%r15
lea    0xe50(%rip),%r12
mov    (%rsp),%r13
jmp    11d9 <cofile+0x79>
movb   $0x0,0x10(%rsp)
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    $0x800,%esi
mov    %rbx,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     1308 <cofile+0x1a8>
mov    %rbp,%rdi
mov    $0xa,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     11ee <cofile+0x8e>
movb   $0x0,(%rax)
mov    %rbp,%rdi
mov    $0x23,%esi
call   1060 <strchr@plt>
cmp    %rbp,%rax
je     11c0 <cofile+0x60>
movzbl 0xe0(%rsp),%eax
cmp    $0x3b,%al
je     11c0 <cofile+0x60>
cmp    $0x5b,%al
jne    1250 <cofile+0xf0>
mov    %r15,%rdi
mov    $0x5d,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     11c0 <cofile+0x60>
movb   $0x0,(%rax)
mov    %r15,%rdi
call   1050 <strlen@plt>
cmp    $0xc7,%eax
ja     11b6 <cofile+0x56>
lea    0x10(%rsp),%rdi
mov    %r15,%rsi
call   1040 <strcpy@plt>
jmp    11c0 <cofile+0x60>
cs nopw 0x0(%rax,%rax,1)
mov    %rbp,%rdi
call   1050 <strlen@plt>
cmp    $0x3,%eax
jl     11c0 <cofile+0x60>
mov    %r12,%rdi
call   1050 <strlen@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %rax,%rdx
call   1030 <strncmp@plt>
cmp    $0x1,%r14d
jne    12e4 <cofile+0x184>
test   %eax,%eax
jne    12e4 <cofile+0x184>
mov    %rbp,%rdi
mov    $0x3d,%esi
call   1060 <strchr@plt>
lea    0x1(%rax),%r8
mov    %r13,%rdi
lea    0xd6a(%rip),%rsi
mov    0x8(%rsp),%r12
mov    %r12,%rdx
mov    %r14d,%r15d
lea    0x10(%rsp),%r14
mov    %r14,%rcx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    %r13,%rdi
lea    0xd56(%rip),%rsi
mov    %r12,%rdx
lea    0xd36(%rip),%r12
mov    %r14,%rcx
mov    %r15d,%r14d
lea    0xe1(%rsp),%r15
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    11c0 <cofile+0x60>
mov    (%rsp),%rdi
lea    0xd36(%rip),%rsi
mov    0x8(%rsp),%rdx
lea    0x10(%rsp),%rcx
mov    %rbp,%r8
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    11c0 <cofile+0x60>
xor    %eax,%eax
add    $0x8e8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"PORT=\00"
@.str.1 = [16 x i8] c"%s.%s.PORT1=%s\0A\00"
@.str.2 = [15 x i8] c"%s.%s.HOST1=*\0A\00"
@.str.3 = [10 x i8] c"%s.%s.%s\0A\00"
define i32 @cofile(i32* %0, i32* %1, i8* %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca [2048 x i8]
%10 = alloca [200 x i8]
%11 = alloca i8*
%12 = alloca i8*
store i32* %0, i32** %5
store i32* %1, i32** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
br label %13
13: ; preds = %96, %4
%14 = getelementptr inbounds [2048 x i8], [2048 x i8]* %9, i64 0, i64 0
%15 = load i32*, i32** %5
%16 = call i64 @fgets(i8* %14, i32 2048, i32* %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %97
18: ; preds = %13
%19 = getelementptr inbounds [2048 x i8], [2048 x i8]* %9, i64 0, i64 0
%20 = call i8* @strchr(i8* %19, i8 signext 10)
store i8* %20, i8** %11
%21 = load i8*, i8** %11
%22 = icmp ne i8* %21, null
br i1 %22, label %23, label %25
23: ; preds = %18
%24 = load i8*, i8** %11
store i8 0, i8* %24
br label %25
25: ; preds = %23, %18
%26 = getelementptr inbounds [2048 x i8], [2048 x i8]* %9, i64 0, i64 0
%27 = call i8* @strchr(i8* %26, i8 signext 35)
%28 = getelementptr inbounds [2048 x i8], [2048 x i8]* %9, i64 0, i64 0
%29 = icmp eq i8* %27, %28
br i1 %29, label %96, label %30
30: ; preds = %25
%31 = getelementptr inbounds [2048 x i8], [2048 x i8]* %9, i64 0, i64 0
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 91
br i1 %34, label %35, label %56
35: ; preds = %30
%36 = getelementptr inbounds [2048 x i8], [2048 x i8]* %9, i64 0, i64 0
%37 = getelementptr inbounds i8, i8* %36, i64 1
store i8* %37, i8** %11
%38 = load i8*, i8** %11
%39 = call i8* @strchr(i8* %38, i8 signext 93)
store i8* %39, i8** %12
%40 = load i8*, i8** %12
%41 = icmp ne i8* %40, null
br i1 %41, label %42, label %55
42: ; preds = %35
%43 = load i8*, i8** %12
store i8 0, i8* %43
%44 = load i8*, i8** %11
%45 = call i32 @strlen(i8* %44)
%46 = sext i32 %45 to i64
%47 = icmp ult i64 %46, 200
br i1 %47, label %48, label %52
48: ; preds = %42
%49 = getelementptr inbounds [200 x i8], [200 x i8]* %10, i64 0, i64 0
%50 = load i8*, i8** %11
%51 = call i32 @strcpy(i8* %49, i8* %50)
br label %54
52: ; preds = %42
%53 = getelementptr inbounds [200 x i8], [200 x i8]* %10, i64 0, i64 0
store i8 0, i8* %53
br label %54
54: ; preds = %52, %48
br label %55
55: ; preds = %54, %35
br label %95
56: ; preds = %30
%57 = getelementptr inbounds [2048 x i8], [2048 x i8]* %9, i64 0, i64 0
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
%60 = icmp ne i32 %59, 59
br i1 %60, label %61, label %94
61: ; preds = %56
%62 = getelementptr inbounds [2048 x i8], [2048 x i8]* %9, i64 0, i64 0
%63 = call i32 @strlen(i8* %62)
%64 = icmp sgt i32 %63, 2
br i1 %64, label %65, label %94
65: ; preds = %61
%66 = getelementptr inbounds [2048 x i8], [2048 x i8]* %9, i64 0, i64 0
%67 = call i8* @strstr(i8* %66, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%68 = getelementptr inbounds [2048 x i8], [2048 x i8]* %9, i64 0, i64 0
%69 = icmp eq i8* %67, %68
br i1 %69, label %70, label %87
70: ; preds = %65
%71 = load i32, i32* %8
%72 = icmp eq i32 %71, 1
br i1 %72, label %73, label %87
73: ; preds = %70
%74 = getelementptr inbounds [2048 x i8], [2048 x i8]* %9, i64 0, i64 0
%75 = call i8* @strchr(i8* %74, i8 signext 61)
store i8* %75, i8** %11
%76 = load i8*, i8** %11
%77 = getelementptr inbounds i8, i8* %76, i32 1
store i8* %77, i8** %11
%78 = load i32*, i32** %6
%79 = load i8*, i8** %7
%80 = getelementptr inbounds [200 x i8], [200 x i8]* %10, i64 0, i64 0
%81 = load i8*, i8** %11
%82 = call i32 (i32*, i8*, i8*, i8*, ...) @fprintf(i32* %78, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %79, i8* %80, i8* %81)
%83 = load i32*, i32** %6
%84 = load i8*, i8** %7
%85 = getelementptr inbounds [200 x i8], [200 x i8]* %10, i64 0, i64 0
%86 = call i32 (i32*, i8*, i8*, i8*, ...) @fprintf(i32* %83, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %84, i8* %85)
br label %93
87: ; preds = %70, %65
%88 = load i32*, i32** %6
%89 = load i8*, i8** %7
%90 = getelementptr inbounds [200 x i8], [200 x i8]* %10, i64 0, i64 0
%91 = getelementptr inbounds [2048 x i8], [2048 x i8]* %9, i64 0, i64 0
%92 = call i32 (i32*, i8*, i8*, i8*, ...) @fprintf(i32* %88, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %89, i8* %90, i8* %91)
br label %93
93: ; preds = %87, %73
br label %94
94: ; preds = %93, %61, %56
br label %95
95: ; preds = %94, %55
br label %96
96: ; preds = %95, %25
br label %13
97: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"PORT=\00"
@.str.1 = [16 x i8] c"%s.%s.PORT1=%s\0A\00"
@.str.2 = [15 x i8] c"%s.%s.HOST1=*\0A\00"
@.str.3 = [10 x i8] c"%s.%s.%s\0A\00"
define i32 @cofile(i32* nocapture %0, i32* nocapture %1, i8* %2, i32 %3) {
%5 = alloca [2048 x i8]
%6 = alloca [200 x i8]
%7 = getelementptr inbounds [2048 x i8], [2048 x i8]* %5, i64 0, i64 0
%8 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%9 = call i64 @fgets(i8* %7, i32 2048, i32* %0)
%10 = icmp eq i64 %9, 0
br i1 %10, label %50, label %11
11: ; preds = %4
%12 = getelementptr inbounds [2048 x i8], [2048 x i8]* %5, i64 0, i64 1
%13 = icmp eq i32 %3, 1
br label %14
14: ; preds = %11, %47
%15 = call i8* @strchr(i8* %7, i8 signext 10)
%16 = icmp eq i8* %15, null
br i1 %16, label %18, label %17
17: ; preds = %14
store i8 0, i8* %15
br label %18
18: ; preds = %17, %14
%19 = call i8* @strchr(i8* %7, i8 signext 35)
%20 = icmp eq i8* %19, %7
br i1 %20, label %47, label %21
21: ; preds = %18
%22 = load i8, i8* %7
switch i8 %22, label %32 [
i8 91, label %23
i8 59, label %47
]
23: ; preds = %21
%24 = call i8* @strchr(i8* %12, i8 signext 93)
%25 = icmp eq i8* %24, null
br i1 %25, label %47, label %26
26: ; preds = %23
store i8 0, i8* %24
%27 = call i32 @strlen(i8* %12)
%28 = icmp ult i32 %27, 200
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = call i32 @strcpy(i8* %8, i8* %12)
br label %47
31: ; preds = %26
store i8 0, i8* %8
br label %47
32: ; preds = %21
%33 = call i32 @strlen(i8* %7)
%34 = icmp sgt i32 %33, 2
br i1 %34, label %35, label %47
35: ; preds = %32
%36 = call i64 bitcast (i32 (i8*)* @strlen to i64 (i8*)*)(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%37 = call i32 @strncmp(i8* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 %36)
%38 = icmp eq i32 %37, 0
%39 = and i1 %13, %38
br i1 %39, label %40, label %45
40: ; preds = %35
%41 = call i8* @strchr(i8* %7, i8 signext 61)
%42 = getelementptr inbounds i8, i8* %41, i64 1
%43 = call i32 (i32*, i8*, i8*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %2, i8* %8, i8* %42)
%44 = call i32 (i32*, i8*, i8*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %2, i8* %8)
br label %47
45: ; preds = %35
%46 = call i32 (i32*, i8*, i8*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %2, i8* %8, i8* %7)
br label %47
47: ; preds = %21, %29, %31, %23, %40, %45, %32, %18
%48 = call i64 @fgets(i8* %7, i32 2048, i32* %0)
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %14
50: ; preds = %47, %4
ret i32 0
}