#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*/ bzero(char *, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
char *get_line(int /*<<< orphan*/ *, int /*<<< orphan*/);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strstr(char *, char *);
int wide_convert(char *catfile, char *grp) {
  FILE *pfile;
  FILE *out;
  char *str;
  char *p, *q;
  char FileName[512];
  char LastFileName[512];
  int gotFileName = 0;
  bzero(FileName, 512);
  bzero(LastFileName, 512);
  pfile = fopen(catfile, "r");
  if (!pfile) {
    return (0);
  }
  out = fopen(grp, "w");
  if (!out) {
    fclose(pfile);
    return (0);
  }
  while ((str = get_line(pfile, 0)) != NULL) {
    p = strstr(str, ":");
    bzero(FileName, 512);
    strncpy(FileName, str, p - str);
    if (gotFileName) {
      if (strcmp(FileName, LastFileName)) {
        strcpy(LastFileName, FileName);
        fprintf(out, "File: %s\n", LastFileName);
      }
    }
    if (strlen(LastFileName) == 0) {
      strcpy(LastFileName, FileName);
      gotFileName = 1;
      fprintf(out, "File: %s\n", LastFileName);
    }
    q = strstr(p + 1, ":");
    fprintf(out, "%s\n", p + 1);
  }
  fclose(out);
  fclose(pfile);
  return (1);
}


x86 assembly (clang, -O0):
<wide_convert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x444(%rbp)
lea    -0x240(%rbp),%rdi
mov    $0x200,%esi
call   10b0 <bzero@plt>
lea    -0x440(%rbp),%rdi
mov    $0x200,%esi
call   10b0 <bzero@plt>
mov    -0x10(%rbp),%rdi
lea    0xe16(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    120a <wide_convert+0x6a>
movl   $0x0,-0x4(%rbp)
jmp    138f <wide_convert+0x1ef>
mov    -0x18(%rbp),%rdi
lea    0xded(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    123e <wide_convert+0x9e>
mov    -0x20(%rbp),%rdi
call   1060 <fclose@plt>
movl   $0x0,-0x4(%rbp)
jmp    138f <wide_convert+0x1ef>
jmp    1243 <wide_convert+0xa3>
mov    -0x20(%rbp),%rdi
xor    %esi,%esi
call   1050 <get_line@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     1376 <wide_convert+0x1d6>
mov    -0x30(%rbp),%rdi
lea    0xd9d(%rip),%rsi
call   10c0 <strstr@plt>
mov    %rax,-0x38(%rbp)
lea    -0x240(%rbp),%rdi
mov    $0x200,%esi
call   10b0 <bzero@plt>
lea    -0x240(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rax
mov    -0x30(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1030 <strncpy@plt>
cmpl   $0x0,-0x444(%rbp)
je     12f7 <wide_convert+0x157>
lea    -0x240(%rbp),%rdi
lea    -0x440(%rbp),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     12f2 <wide_convert+0x152>
lea    -0x440(%rbp),%rdi
lea    -0x240(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x28(%rbp),%rdi
lea    -0x440(%rbp),%rdx
lea    0xd19(%rip),%rsi
call   1090 <fprintf@plt>
jmp    12f7 <wide_convert+0x157>
lea    -0x440(%rbp),%rdi
call   1070 <strlen@plt>
cmp    $0x0,%rax
jne    1341 <wide_convert+0x1a1>
lea    -0x440(%rbp),%rdi
lea    -0x240(%rbp),%rsi
call   1040 <strcpy@plt>
movl   $0x1,-0x444(%rbp)
mov    -0x28(%rbp),%rdi
lea    -0x440(%rbp),%rdx
lea    0xcca(%rip),%rsi
call   1090 <fprintf@plt>
mov    -0x38(%rbp),%rdi
add    $0x1,%rdi
lea    0xcb4(%rip),%rsi
call   10c0 <strstr@plt>
mov    %rax,-0x40(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x38(%rbp),%rdx
add    $0x1,%rdx
lea    0xca0(%rip),%rsi
call   1090 <fprintf@plt>
jmp    1243 <wide_convert+0xa3>
mov    -0x28(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1060 <fclose@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wide_convert>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %rsi,%rbx
mov    %rdi,%rbp
lea    0x210(%rsp),%rdi
mov    $0x200,%esi
call   10b0 <bzero@plt>
lea    0x10(%rsp),%rdi
mov    $0x200,%esi
call   10b0 <bzero@plt>
lea    0xe31(%rip),%rsi
mov    %rbp,%rdi
call   10a0 <fopen@plt>
xor    %ebp,%ebp
mov    %rax,0x8(%rsp)
test   %rax,%rax
je     1313 <wide_convert+0x183>
lea    0xe14(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1309 <wide_convert+0x179>
mov    %rax,%r15
xor    %r14d,%r14d
mov    0x8(%rsp),%rdi
xor    %esi,%esi
call   1050 <get_line@plt>
test   %rax,%rax
je     12f0 <wide_convert+0x160>
mov    %rax,%rbp
lea    0x210(%rsp),%rbx
lea    0x10(%rsp),%r12
jmp    125e <wide_convert+0xce>
nopl   0x0(%rax)
add    $0x1,%r13
mov    %r15,%rdi
lea    0xdcc(%rip),%rsi
mov    %r13,%rdx
call   1090 <fprintf@plt>
mov    0x8(%rsp),%rdi
xor    %esi,%esi
call   1050 <get_line@plt>
mov    %rax,%rbp
test   %rax,%rax
je     12f0 <wide_convert+0x160>
mov    %rbp,%rdi
mov    $0x3a,%esi
call   1070 <strchr@plt>
mov    %rax,%r13
mov    %rbx,%rdi
mov    $0x200,%esi
call   10b0 <bzero@plt>
mov    %r13d,%edx
sub    %ebp,%edx
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1030 <strncpy@plt>
test   %r14d,%r14d
je     12bd <wide_convert+0x12d>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     12bd <wide_convert+0x12d>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
mov    %r15,%rdi
lea    0xd4f(%rip),%rsi
mov    %r12,%rdx
call   1090 <fprintf@plt>
cmpb   $0x0,0x10(%rsp)
jne    1230 <wide_convert+0xa0>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
mov    %r15,%rdi
lea    0xd27(%rip),%rsi
mov    %r12,%rdx
call   1090 <fprintf@plt>
mov    $0x1,%r14d
jmp    1230 <wide_convert+0xa0>
mov    %r15,%rdi
call   1060 <fclose@plt>
mov    0x8(%rsp),%rdi
call   1060 <fclose@plt>
mov    $0x1,%ebp
jmp    1313 <wide_convert+0x183>
mov    0x8(%rsp),%rdi
call   1060 <fclose@plt>
mov    %ebp,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c"w\00"
@.str.3 = [10 x i8] c"File: %s\0A\00"
@.str.4 = [4 x i8] c"%s\0A\00"
define i32 @wide_convert(i8* nocapture %0, i8* nocapture %1) {
%3 = alloca [512 x i8]
%4 = alloca [512 x i8]
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%7 = call i32 @bzero(i8* %5, i32 512)
%8 = call i32 @bzero(i8* %6, i32 512)
%9 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %51, label %11
11: ; preds = %2
%12 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %17, label %14
14: ; preds = %11
%15 = call i8* @get_line(i32* %9, i32 0)
%16 = icmp eq i8* %15, null
br i1 %16, label %48, label %19
17: ; preds = %11
%18 = tail call i32 @fclose(i32* %9)
br label %51
19: ; preds = %14, %42
%20 = phi i8* [ %46, %42 ], [ %15, %14 ]
%21 = phi i32 [ %43, %42 ], [ 0, %14 ]
%22 = call i8* @strchr(i8* %20, i32 58)
%23 = call i32 @bzero(i8* %5, i32 512)
%24 = ptrtoint i8* %22 to i64
%25 = ptrtoint i8* %20 to i64
%26 = sub i64 %24, %25
%27 = trunc i64 %26 to i32
%28 = call i32 @strncpy(i8* %5, i8* %20, i32 %27)
%29 = icmp eq i32 %21, 0
br i1 %29, label %36, label %30
30: ; preds = %19
%31 = call i64 @strcmp(i8* %5, i8* %6)
%32 = icmp eq i64 %31, 0
br i1 %32, label %36, label %33
33: ; preds = %30
%34 = call i32 @strcpy(i8* %6, i8* %5)
%35 = call i32 @fprintf(i32* %12, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %6)
br label %36
36: ; preds = %30, %33, %19
%37 = load i8, i8* %6
%38 = icmp eq i8 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %36
%40 = call i32 @strcpy(i8* %6, i8* %5)
%41 = call i32 @fprintf(i32* %12, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %6)
br label %42
42: ; preds = %39, %36
%43 = phi i32 [ 1, %39 ], [ %21, %36 ]
%44 = getelementptr inbounds i8, i8* %22, i64 1
%45 = call i32 @fprintf(i32* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %44)
%46 = call i8* @get_line(i32* %9, i32 0)
%47 = icmp eq i8* %46, null
br i1 %47, label %48, label %19
48: ; preds = %42, %14
%49 = call i32 @fclose(i32* %12)
%50 = call i32 @fclose(i32* %9)
br label %51
51: ; preds = %2, %48, %17
%52 = phi i32 [ 1, %48 ], [ 0, %17 ], [ 0, %2 ]
ret i32 %52
}