#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 EOF;
int fscanf(int /*<<< orphan*/ *, char *, char *);
int read_line(FILE *src, char *label, char *opcode, char *operand) {
  int bytes = 0, t, temp;
  bytes += ((t = fscanf(src, "%s", label)) == EOF) ? 0 : t;
  bytes += ((t = fscanf(src, "%s", opcode)) == EOF) ? 0 : t;
  bytes += ((t = fscanf(src, "%s", operand)) == EOF) ? 0 : t;
  return bytes;
}


x86 assembly (clang, -O0):
<read_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xec2(%rip),%rsi
call   1030 <fscanf@plt>
mov    %eax,-0x28(%rbp)
mov    0x2e9b(%rip),%rcx
cmp    (%rcx),%eax
jne    115f <read_line+0x4f>
xor    %eax,%eax
mov    %eax,-0x30(%rbp)
jmp    1165 <read_line+0x55>
mov    -0x28(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe83(%rip),%rsi
call   1030 <fscanf@plt>
mov    %eax,-0x28(%rbp)
mov    0x2e5c(%rip),%rcx
cmp    (%rcx),%eax
jne    119e <read_line+0x8e>
xor    %eax,%eax
mov    %eax,-0x34(%rbp)
jmp    11a4 <read_line+0x94>
mov    -0x28(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe44(%rip),%rsi
call   1030 <fscanf@plt>
mov    %eax,-0x28(%rbp)
mov    0x2e1d(%rip),%rcx
cmp    (%rcx),%eax
jne    11dd <read_line+0xcd>
xor    %eax,%eax
mov    %eax,-0x38(%rbp)
jmp    11e3 <read_line+0xd3>
mov    -0x28(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_line>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,(%rsp)
mov    %rdx,%r15
mov    %rsi,%rdx
mov    %rdi,%r13
lea    0xed1(%rip),%rbx
mov    %rbx,%rsi
call   1030 <fscanf@plt>
mov    %eax,%ebp
mov    0x2ea8(%rip),%r14
xor    %r12d,%r12d
cmp    (%r14),%eax
cmove  %r12d,%ebp
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1030 <fscanf@plt>
mov    %eax,%ebx
cmp    (%r14),%eax
cmove  %r12d,%ebx
add    %ebp,%ebx
mov    %r13,%rdi
lea    0xe93(%rip),%rsi
mov    (%rsp),%rdx
call   1030 <fscanf@plt>
cmp    (%r14),%eax
cmove  %r12d,%eax
add    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@EOF = global i32 0
define i32 @read_line(i32* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32* %0, i32** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
store i32 0, i32* %9
%12 = load i32*, i32** %5
%13 = load i8*, i8** %6
%14 = call i32 @fscanf(i32* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %13)
store i32 %14, i32* %10
%15 = load i32, i32* @EOF
%16 = icmp eq i32 %14, %15
br i1 %16, label %17, label %18
17: ; preds = %4
br label %20
18: ; preds = %4
%19 = load i32, i32* %10
br label %20
20: ; preds = %18, %17
%21 = phi i32 [ 0, %17 ], [ %19, %18 ]
%22 = load i32, i32* %9
%23 = add nsw i32 %22, %21
store i32 %23, i32* %9
%24 = load i32*, i32** %5
%25 = load i8*, i8** %7
%26 = call i32 @fscanf(i32* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %25)
store i32 %26, i32* %10
%27 = load i32, i32* @EOF
%28 = icmp eq i32 %26, %27
br i1 %28, label %29, label %30
29: ; preds = %20
br label %32
30: ; preds = %20
%31 = load i32, i32* %10
br label %32
32: ; preds = %30, %29
%33 = phi i32 [ 0, %29 ], [ %31, %30 ]
%34 = load i32, i32* %9
%35 = add nsw i32 %34, %33
store i32 %35, i32* %9
%36 = load i32*, i32** %5
%37 = load i8*, i8** %8
%38 = call i32 @fscanf(i32* %36, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %37)
store i32 %38, i32* %10
%39 = load i32, i32* @EOF
%40 = icmp eq i32 %38, %39
br i1 %40, label %41, label %42
41: ; preds = %32
br label %44
42: ; preds = %32
%43 = load i32, i32* %10
br label %44
44: ; preds = %42, %41
%45 = phi i32 [ 0, %41 ], [ %43, %42 ]
%46 = load i32, i32* %9
%47 = add nsw i32 %46, %45
store i32 %47, i32* %9
%48 = load i32, i32* %9
ret i32 %48
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@EOF = global i32 0
define i32 @read_line(i32* nocapture %0, i8* %1, i8* %2, i8* %3) {
%5 = tail call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %1)
%6 = load i32, i32* @EOF
%7 = icmp eq i32 %5, %6
%8 = select i1 %7, i32 0, i32 %5
%9 = tail call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%10 = load i32, i32* @EOF
%11 = icmp eq i32 %9, %10
%12 = select i1 %11, i32 0, i32 %9
%13 = add nsw i32 %12, %8
%14 = tail call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%15 = load i32, i32* @EOF
%16 = icmp eq i32 %14, %15
%17 = select i1 %16, i32 0, i32 %14
%18 = add nsw i32 %13, %17
ret i32 %18
}