#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*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int sscanf(char *, char *, char *, char *);
int main() {
  int linecount = 0;
  char line[120];
  FILE *fp = fopen("data.csv", "r");
  while (fgets(line, sizeof(line), fp) != NULL) {
    linecount++;
    printf("%d %s", linecount, line);
  }
  fclose(fp);
  char myline[] = "Steven Seagal;123 Cool St;";
  char name[20];
  char address[12];
  if (sscanf(myline, "%14[^;]s %12[^;]s", name, address) == 2) {
    printf("%s %s\n", name, address);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xe90(%rip),%rdi
lea    0xe92(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x88(%rbp)
lea    -0x80(%rbp),%rdi
mov    -0x88(%rbp),%rdx
mov    $0x78,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     11c5 <main+0x75>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    -0x80(%rbp),%rdx
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1183 <main+0x33>
mov    -0x88(%rbp),%rdi
call   1030 <fclose@plt>
mov    0xe58(%rip),%rax
mov    %rax,-0xb0(%rbp)
mov    0xe52(%rip),%rax
mov    %rax,-0xa8(%rbp)
mov    0xe4c(%rip),%rax
mov    %rax,-0xa0(%rbp)
mov    0xe46(%rip),%ax
mov    %ax,-0x98(%rbp)
mov    0xe3b(%rip),%al
mov    %al,-0x96(%rbp)
lea    -0xb0(%rbp),%rdi
lea    -0xd0(%rbp),%rdx
lea    -0xdc(%rbp),%rcx
lea    0xde0(%rip),%rsi
call   1060 <sscanf@plt>
cmp    $0x2,%eax
jne    125b <main+0x10b>
lea    -0xd0(%rbp),%rsi
lea    -0xdc(%rbp),%rdx
lea    0xdcf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0xc8,%rsp
lea    0xe9c(%rip),%rdi
lea    0xe9e(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r15
lea    0x50(%rsp),%rdi
mov    $0x78,%esi
mov    %rax,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     11c7 <main+0x77>
mov    $0x1,%ebp
lea    0xe75(%rip),%r14
lea    0x50(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x78,%esi
mov    %r15,%rdx
call   1050 <fgets@plt>
add    $0x1,%ebp
test   %rax,%rax
jne    11a0 <main+0x50>
mov    %r15,%rdi
call   1030 <fclose@plt>
movups 0xe65(%rip),%xmm0
movups %xmm0,0x1b(%rsp)
movaps 0xe4e(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0xe23(%rip),%rsi
lea    0x10(%rsp),%rdi
lea    0x30(%rsp),%rdx
lea    0x4(%rsp),%rcx
call   1060 <sscanf@plt>
cmp    $0x2,%eax
jne    121f <main+0xcf>
lea    0xe15(%rip),%rdi
lea    0x30(%rsp),%rsi
lea    0x4(%rsp),%rdx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xc8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"data.csv\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [6 x i8] c"%d %s\00"
@__const.main.myline = [27 x i8] c"Steven Seagal;123 Cool St;\00"
@.str.3 = [18 x i8] c"%14[^;]s %12[^;]s\00"
@.str.4 = [7 x i8] c"%s %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [120 x i8]
%4 = alloca i32*
%5 = alloca [27 x i8]
%6 = alloca [20 x i8]
%7 = alloca [12 x i8]
store i32 0, i32* %1
store i32 0, i32* %2
%8 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %4
br label %9
9: ; preds = %14, %0
%10 = getelementptr inbounds [120 x i8], [120 x i8]* %3, i64 0, i64 0
%11 = load i32*, i32** %4
%12 = call i32* @fgets(i8* %10, i32 120, i32* %11)
%13 = icmp ne i32* %12, null
br i1 %13, label %14, label %20
14: ; preds = %9
%15 = load i32, i32* %2
%16 = add nsw i32 %15, 1
store i32 %16, i32* %2
%17 = load i32, i32* %2
%18 = getelementptr inbounds [120 x i8], [120 x i8]* %3, i64 0, i64 0
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %17, i8* %18)
br label %9
20: ; preds = %9
%21 = load i32*, i32** %4
%22 = call i32 @fclose(i32* %21)
%23 = bitcast [27 x i8]* %5 to i8*
%24 = getelementptr inbounds [27 x i8], [27 x i8]* %5, i64 0, i64 0
%25 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%26 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 0
%27 = call i32 @sscanf(i8* %24, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %25, i8* %26)
%28 = icmp eq i32 %27, 2
br i1 %28, label %29, label %33
29: ; preds = %20
%30 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%31 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 0
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %30, i8* %31)
br label %33
33: ; preds = %29, %20
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"data.csv\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [6 x i8] c"%d %s\00"
@__const.main.myline = [27 x i8] c"Steven Seagal;123 Cool St;\00"
@.str.3 = [18 x i8] c"%14[^;]s %12[^;]s\00"
@.str.4 = [7 x i8] c"%s %s\0A\00"
define i32 @main() {
%1 = alloca [120 x i8]
%2 = alloca [27 x i8]
%3 = alloca [20 x i8]
%4 = alloca [12 x i8]
%5 = getelementptr inbounds [120 x i8], [120 x i8]* %1, i64 0, i64 0
%6 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32* @fgets(i8* %5, i32 120, i32* %6)
%8 = icmp eq i32* %7, null
br i1 %8, label %15, label %9
9: ; preds = %0, %9
%10 = phi i32 [ %11, %9 ], [ 0, %0 ]
%11 = add nuw nsw i32 %10, 1
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %11, i8* %5)
%13 = call i32* @fgets(i8* %5, i32 120, i32* %6)
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %9
15: ; preds = %9, %0
%16 = call i32 @fclose(i32* %6)
%17 = getelementptr inbounds [27 x i8], [27 x i8]* %2, i64 0, i64 0
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%19 = getelementptr inbounds [12 x i8], [12 x i8]* %4, i64 0, i64 0
%20 = call i32 @sscanf(i8* %17, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %18, i8* %19)
%21 = icmp eq i32 %20, 2
br i1 %21, label %22, label %24
22: ; preds = %15
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %18, i8* %19)
br label %24
24: ; preds = %22, %15
ret i32 0
}