#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 */

/* Variables and functions */
int scanf(char *, int *, int *, int *);
int ler_acessos(int *id, int *tempo) {
  int numAcessos;
  for (numAcessos = 0; numAcessos < 100; ++numAcessos) {
    int entrada, saida;
    if (scanf("%d %d %d", id + numAcessos, &entrada, &saida) < 3) {
      break;
    }
    tempo[numAcessos] = saida - entrada;
  }
  return numAcessos;
}


x86 assembly (clang, -O0):
<ler_acessos>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x64,-0x14(%rbp)
jge    1181 <ler_acessos+0x71>
mov    -0x8(%rbp),%rsi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xeb9(%rip),%rdi
lea    -0x18(%rbp),%rdx
lea    -0x1c(%rbp),%rcx
call   1030 <scanf@plt>
cmp    $0x3,%eax
jge    1162 <ler_acessos+0x52>
jmp    1181 <ler_acessos+0x71>
mov    -0x1c(%rbp),%edx
sub    -0x18(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1127 <ler_acessos+0x17>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ler_acessos>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
lea    0xed6(%rip),%r12
lea    0x4(%rsp),%r13
mov    %rsp,%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r13,%rdx
mov    %rbp,%rcx
call   1030 <scanf@plt>
cmp    $0x2,%eax
jle    1174 <ler_acessos+0x64>
mov    (%rsp),%eax
sub    0x4(%rsp),%eax
mov    %eax,(%r14,%rbx,4)
add    $0x1,%rbx
add    $0x4,%r15
cmp    $0x64,%rbx
jne    1140 <ler_acessos+0x30>
mov    $0x64,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%d %d %d\00"
define i32 @ler_acessos(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
store i32 0, i32* %5
br label %8
8: ; preds = %27, %2
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 100
br i1 %10, label %11, label %30
11: ; preds = %8
%12 = load i32*, i32** %3
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i32, i32* %12, i64 %14
%16 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %15, i32* %6, i32* %7)
%17 = icmp slt i32 %16, 3
br i1 %17, label %18, label %19
18: ; preds = %11
br label %30
19: ; preds = %11
%20 = load i32, i32* %7
%21 = load i32, i32* %6
%22 = sub nsw i32 %20, %21
%23 = load i32*, i32** %4
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32, i32* %23, i64 %25
store i32 %22, i32* %26
br label %27
27: ; preds = %19
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
br label %8
30: ; preds = %18, %8
%31 = load i32, i32* %5
ret i32 %31
}

LLVM IR (-O2):
@.str = [9 x i8] c"%d %d %d\00"
define i32 @ler_acessos(i32* %0, i32* nocapture writeonly %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
br label %7
7: ; preds = %2, %14
%8 = phi i64 [ 0, %2 ], [ %19, %14 ]
%9 = getelementptr inbounds i32, i32* %0, i64 %8
%10 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %9, i32* %3, i32* %4)
%11 = icmp slt i32 %10, 3
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = trunc i64 %8 to i32
br label %21
14: ; preds = %7
%15 = load i32, i32* %4
%16 = load i32, i32* %3
%17 = sub nsw i32 %15, %16
%18 = getelementptr inbounds i32, i32* %1, i64 %8
store i32 %17, i32* %18
%19 = add nuw nsw i64 %8, 1
%20 = icmp eq i64 %19, 100
br i1 %20, label %21, label %7
21: ; preds = %14, %12
%22 = phi i32 [ %13, %12 ], [ 100, %14 ]
ret i32 %22
}