#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 fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int);
int R_iso_getLine(FILE *fp, int v[], int *zs) {
  int i, ch;
  int z = 0;
  i = 0;
  ch = fgetc(fp);
  printf("%d\n", ch);
  v[i] = ch - 65;
  while (ch != 10) {
    i++;
    ch = fgetc(fp);
    v[i] = ch - 65;
    if (v[i] == 25)
      z++;
  }
  (*zs) = z;
  return i;
}


x86 assembly (clang, -O0):
<R_iso_getLine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%esi
lea    0xea8(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%edx
sub    $0x41,%edx
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
cmpl   $0xa,-0x20(%rbp)
je     11be <R_iso_getLine+0x9e>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%edx
sub    $0x41,%edx
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpl   $0x19,(%rax,%rcx,4)
jne    11b9 <R_iso_getLine+0x99>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    116e <R_iso_getLine+0x4e>
mov    -0x24(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<R_iso_getLine>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %rdi,%r12
call   1040 <fgetc@plt>
mov    %eax,%r13d
lea    0xebd(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    -0x41(%r13),%eax
mov    %eax,(%r15)
xor    %r14d,%r14d
mov    $0x0,%ebp
cmp    $0xa,%r13d
je     1199 <R_iso_getLine+0x79>
mov    %rbx,%r13
xor    %r14d,%r14d
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    %r14,%rbx
add    $0x1,%r14
mov    %r12,%rdi
call   1040 <fgetc@plt>
lea    -0x41(%rax),%ecx
mov    %ecx,0x4(%r15,%rbx,4)
xor    %edx,%edx
cmp    $0x19,%ecx
sete   %dl
add    %edx,%ebp
cmp    $0xa,%eax
jne    1170 <R_iso_getLine+0x50>
mov    %r13,%rbx
mov    %ebp,(%rbx)
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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