#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*/ exit(int /*<<< orphan*/);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int, int, int);
void advance(FILE *fp) {
  int i = 0;
  int curr_char = fgetc(fp);
  int next_char = fgetc(fp);
  int next_char2 = fgetc(fp);
  while ((next_char2 != '\0' && i < 30)) {
    printf("%c %c %c\n", curr_char, next_char, next_char2);
    curr_char = next_char;
    next_char = next_char2;
    next_char2 = fgetc(fp);
    i++;
  }
  exit(0);
}


x86 assembly (clang, -O0):
<advance>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x18(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x18(%rbp)
mov    %al,-0x19(%rbp)
je     1180 <advance+0x50>
cmpl   $0x1e,-0xc(%rbp)
setl   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1190 <advance+0x60>
jmp    11cb <advance+0x9b>
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xe60(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1167 <advance+0x37>
xor    %edi,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<advance>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r14
call   1040 <fgetc@plt>
mov    %eax,%r12d
mov    %r14,%rdi
call   1040 <fgetc@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1040 <fgetc@plt>
test   %eax,%eax
je     119b <advance+0x6b>
xor    %ebx,%ebx
lea    0xe9e(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12d,%esi
mov    %ebp,%r12d
mov    %eax,%ebp
mov    %r15,%rdi
mov    %r12d,%edx
mov    %eax,%ecx
call   1030 <printf@plt>
mov    %r14,%rdi
call   1040 <fgetc@plt>
test   %eax,%eax
je     119b <advance+0x6b>
lea    0x1(%rbx),%ecx
cmp    $0x1d,%ebx
mov    %ecx,%ebx
jb     1170 <advance+0x40>
xor    %edi,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"%c %c %c\0A\00"
define void @advance(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %3
%7 = load i32*, i32** %2
%8 = call i32 @fgetc(i32* %7)
store i32 %8, i32* %4
%9 = load i32*, i32** %2
%10 = call i32 @fgetc(i32* %9)
store i32 %10, i32* %5
%11 = load i32*, i32** %2
%12 = call i32 @fgetc(i32* %11)
store i32 %12, i32* %6
br label %13
13: ; preds = %21, %1
%14 = load i32, i32* %6
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = load i32, i32* %3
%18 = icmp slt i32 %17, 30
br label %19
19: ; preds = %16, %13
%20 = phi i1 [ false, %13 ], [ %18, %16 ]
br i1 %20, label %21, label %32
21: ; preds = %19
%22 = load i32, i32* %4
%23 = load i32, i32* %5
%24 = load i32, i32* %6
%25 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %22, i32 %23, i32 %24)
%26 = load i32, i32* %5
store i32 %26, i32* %4
%27 = load i32, i32* %6
store i32 %27, i32* %5
%28 = load i32*, i32** %2
%29 = call i32 @fgetc(i32* %28)
store i32 %29, i32* %6
%30 = load i32, i32* %3
%31 = add nsw i32 %30, 1
store i32 %31, i32* %3
br label %13
32: ; preds = %19
%33 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [10 x i8] c"%c %c %c\0A\00"
define void @advance(i32* nocapture %0) {
%2 = tail call i32 @fgetc(i32* %0)
%3 = tail call i32 @fgetc(i32* %0)
%4 = tail call i32 @fgetc(i32* %0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %17, label %6
6: ; preds = %1, %6
%7 = phi i32 [ %12, %6 ], [ %4, %1 ]
%8 = phi i32 [ %7, %6 ], [ %3, %1 ]
%9 = phi i32 [ %8, %6 ], [ %2, %1 ]
%10 = phi i32 [ %13, %6 ], [ 0, %1 ]
%11 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %8, i32 %7)
%12 = tail call i32 @fgetc(i32* %0)
%13 = add nuw nsw i32 %10, 1
%14 = icmp ne i32 %12, 0
%15 = icmp ult i32 %10, 29
%16 = select i1 %14, i1 %15, i1 false
br i1 %16, label %6, label %17
17: ; preds = %6, %1
%18 = tail call i32 @exit(i32 0)
unreachable
}