#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*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int strlen(char *);
int main() {
  char linhaOriginal[200], linhaSaida[200];
  FILE *entrada, *saida;
  int i, j;
  int ignorar;
  entrada = fopen("../brutos/idhm2000.csv", "r");
  saida = fopen("../tratados/idhm2000.csv", "w");
  while (fgets(linhaOriginal, 200, entrada) != NULL) {
    ignorar = 0;
    j = 0;
    printf("%s", linhaOriginal);
    linhaSaida[j] = '"';
    j++;
    for (i = 0; i < strlen(linhaOriginal); i++) {
      if (linhaOriginal[i] == '(') {
        linhaSaida[j - 1] = '"';
        linhaSaida[j] = ',';
        j++;
        linhaSaida[j] = '"';
        j++;
        continue;
      }
      if (linhaOriginal[i] == ')') {
        linhaSaida[j] = '"';
        j++;
        continue;
      }
      if (linhaOriginal[i] == '\n') {
        linhaSaida[j - 1] = '\0';
        break;
      }
      linhaSaida[j] = linhaOriginal[i];
      j++;
    }
    fprintf(saida, "%s,2000\n", linhaSaida);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe97(%rip),%rdi
lea    0xea7(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x1a8(%rbp)
lea    0xe96(%rip),%rdi
lea    0xea8(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x1b0(%rbp)
lea    -0xd0(%rbp),%rdi
mov    -0x1a8(%rbp),%rdx
mov    $0xc8,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     1364 <main+0x214>
movl   $0x0,-0x1bc(%rbp)
movl   $0x0,-0x1b8(%rbp)
lea    -0xd0(%rbp),%rsi
lea    0xe5a(%rip),%rdi
call   1040 <printf@plt>
movslq -0x1b8(%rbp),%rax
movb   $0x22,-0x1a0(%rbp,%rax,1)
22
mov    -0x1b8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1b8(%rbp)
movl   $0x0,-0x1b4(%rbp)
mov    -0x1b4(%rbp),%eax
mov    %eax,-0x1c0(%rbp)
lea    -0xd0(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c0(%rbp),%eax
cmp    %ecx,%eax
jge    1345 <main+0x1f5>
movslq -0x1b4(%rbp),%rax
movsbl -0xd0(%rbp,%rax,1),%eax
ff
cmp    $0x28,%eax
jne    129b <main+0x14b>
mov    -0x1b8(%rbp),%eax
sub    $0x1,%eax
cltq
movb   $0x22,-0x1a0(%rbp,%rax,1)
22
movslq -0x1b8(%rbp),%rax
movb   $0x2c,-0x1a0(%rbp,%rax,1)
2c
mov    -0x1b8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1b8(%rbp)
movslq -0x1b8(%rbp),%rax
movb   $0x22,-0x1a0(%rbp,%rax,1)
22
mov    -0x1b8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1b8(%rbp)
jmp    1331 <main+0x1e1>
movslq -0x1b4(%rbp),%rax
movsbl -0xd0(%rbp,%rax,1),%eax
ff
cmp    $0x29,%eax
jne    12d6 <main+0x186>
movslq -0x1b8(%rbp),%rax
movb   $0x22,-0x1a0(%rbp,%rax,1)
22
mov    -0x1b8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1b8(%rbp)
jmp    1331 <main+0x1e1>
movslq -0x1b4(%rbp),%rax
movsbl -0xd0(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
jne    1306 <main+0x1b6>
mov    -0x1b8(%rbp),%eax
sub    $0x1,%eax
cltq
movb   $0x0,-0x1a0(%rbp,%rax,1)
jmp    1345 <main+0x1f5>
movslq -0x1b4(%rbp),%rax
mov    -0xd0(%rbp,%rax,1),%cl
movslq -0x1b8(%rbp),%rax
mov    %cl,-0x1a0(%rbp,%rax,1)
mov    -0x1b8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1b8(%rbp)
mov    -0x1b4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1b4(%rbp)
jmp    1207 <main+0xb7>
mov    -0x1b0(%rbp),%rdi
lea    -0x1a0(%rbp),%rdx
lea    0xcdd(%rip),%rsi
call   1060 <fprintf@plt>
jmp    1196 <main+0x46>
xor    %eax,%eax
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x198,%rsp
lea    0xe98(%rip),%rdi
lea    0xea8(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r14
lea    0xe9b(%rip),%rdi
lea    0xead(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r12
lea    0xd0(%rsp),%rdi
mov    $0xc8,%esi
mov    %r14,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     126e <main+0x11e>
lea    0xd0(%rsp),%rbx
mov    %rsp,%r13
jmp    11f7 <main+0xa7>
movslq %r15d,%rax
movb   $0x0,-0x1(%rax,%r13,1)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
lea    0xe5d(%rip),%rsi
mov    %r13,%rdx
call   1060 <fprintf@plt>
mov    %rbx,%rdi
mov    $0xc8,%esi
mov    %r14,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     126e <main+0x11e>
lea    0xe36(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
movb   $0x22,(%rsp)
mov    %rbx,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    11d0 <main+0x80>
mov    $0x1,%r15d
xor    %ebp,%ebp
jmp    124d <main+0xfd>
movslq %r15d,%rcx
movw   $0x2c22,-0x1(%rcx,%r13,1)
2c
add    $0x1,%r15d
movslq %r15d,%r15
mov    %al,(%rsp,%r15,1)
add    $0x1,%r15d
add    $0x1,%rbp
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbp
jge    11d0 <main+0x80>
movzbl 0xd0(%rsp,%rbp,1),%ecx
mov    $0x22,%al
cmp    $0x28,%cl
je     1220 <main+0xd0>
cmp    $0x29,%cl
je     122f <main+0xdf>
cmp    $0xa,%cl
je     11b8 <main+0x68>
mov    %ecx,%eax
jmp    122f <main+0xdf>
xor    %eax,%eax
add    $0x198,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [23 x i8] c"../brutos/idhm2000.csv\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [25 x i8] c"../tratados/idhm2000.csv\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [9 x i8] c"%s,2000\0A\00"
define i32 @main() {
%1 = alloca [200 x i8]
%2 = alloca [200 x i8]
%3 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32* @fopen(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%7 = call i32* @fgets(i8* %3, i32 200, i32* %5)
%8 = icmp eq i32* %7, null
br i1 %8, label %44, label %9
9: ; preds = %0, %40
%10 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %3)
store i8 34, i8* %4
%11 = call i32 @strlen(i8* %3)
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %40
13: ; preds = %9, %30
%14 = phi i64 [ %36, %30 ], [ 0, %9 ]
%15 = phi i32 [ %35, %30 ], [ 1, %9 ]
%16 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 %14
%17 = load i8, i8* %16
switch i8 %17, label %29 [
i8 40, label %18
i8 41, label %30
i8 10, label %25
]
18: ; preds = %13
%19 = add nsw i32 %15, -1
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 %20
store i8 34, i8* %21
%22 = sext i32 %15 to i64
%23 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 %22
store i8 44, i8* %23
%24 = add nsw i32 %15, 1
br label %30
25: ; preds = %13
%26 = add nsw i32 %15, -1
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 %27
store i8 0, i8* %28
br label %40
29: ; preds = %13
br label %30
30: ; preds = %13, %29, %18
%31 = phi i32 [ %15, %29 ], [ %24, %18 ], [ %15, %13 ]
%32 = phi i8 [ %17, %29 ], [ 34, %18 ], [ 34, %13 ]
%33 = sext i32 %31 to i64
%34 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 %33
store i8 %32, i8* %34
%35 = add nsw i32 %31, 1
%36 = add nuw nsw i64 %14, 1
%37 = call i32 @strlen(i8* %3)
%38 = sext i32 %37 to i64
%39 = icmp slt i64 %36, %38
br i1 %39, label %13, label %40
40: ; preds = %30, %9, %25
%41 = call i32 @fprintf(i32* %6, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* %4)
%42 = call i32* @fgets(i8* %3, i32 200, i32* %5)
%43 = icmp eq i32* %42, null
br i1 %43, label %44, label %9
44: ; preds = %40, %0
ret i32 0
}