#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);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ printf(char *);
int main(int argc, char *argv[]) {
  int x, i;
  FILE *fin = fopen(argv[1], "r");
  if (argc < 1) {
    printf("Usage: hoppity <in.txt>\n");
    exit(1);
  }
  if (fin == NULL) {
    printf("Usage: hoppity <in.txt>\n");
    exit(1);
  }
  fscanf(fin, "%d", &x);
  fclose(fin);
  for (i = 1; i < (x + 1); i++) {
    if (i % 3 == 0) {
      if (i % 5 == 0) {
        printf("Hop\n");
      } else {
        printf("Hoppity\n");
      }
    } else if (i % 5 == 0) {
      printf("Hophop\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe8b(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpl   $0x1,-0x8(%rbp)
jge    119e <main+0x4e>
lea    0xe73(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
cmpq   $0x0,-0x20(%rbp)
jne    11bf <main+0x6f>
lea    0xe52(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x20(%rbp),%rdi
lea    0xe51(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1050 <fscanf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    1276 <main+0x126>
mov    -0x18(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    123e <main+0xee>
mov    -0x18(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    122d <main+0xdd>
lea    0xdfb(%rip),%rdi
call   1040 <printf@plt>
jmp    1239 <main+0xe9>
lea    0xdef(%rip),%rdi
call   1040 <printf@plt>
jmp    1263 <main+0x113>
mov    -0x18(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    125e <main+0x10e>
lea    0xdd3(%rip),%rdi
call   1040 <printf@plt>
jmp    1263 <main+0x113>
jmp    1268 <main+0x118>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11e3 <main+0x93>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%ebp
mov    0x8(%rsi),%rdi
lea    0xe98(%rip),%rsi
call   1060 <fopen@plt>
test   %ebp,%ebp
jle    123a <main+0xea>
mov    %rax,%rbx
test   %rax,%rax
je     123a <main+0xea>
lea    0xe7a(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rbx,%rdi
call   1050 <fscanf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
cmpl   $0x0,0x4(%rsp)
jle    1229 <main+0xd9>
mov    $0x1,%ebx
xor    %ebp,%ebp
mov    $0xaaaaaaab,%r14d
mov    $0xcccccccd,%r15d
lea    0xe52(%rip),%r12
lea    0xe3c(%rip),%r13
jmp    11e1 <main+0x91>
nopl   0x0(%rax,%rax,1)
call   1030 <puts@plt>
add    $0x1,%ebx
add    $0x1,%ebp
cmp    0x4(%rsp),%ebp
jge    1229 <main+0xd9>
mov    %ebx,%eax
mov    %rax,%rcx
imul   %r14,%rcx
shr    $0x21,%rcx
lea    (%rcx,%rcx,2),%ecx
add    $0xffffffff,%ecx
imul   %r15,%rax
shr    $0x22,%rax
lea    (%rax,%rax,4),%eax
add    $0xffffffff,%eax
cmp    %ebp,%ecx
jne    1220 <main+0xd0>
mov    %r12,%rdi
cmp    %ebp,%eax
je     11d0 <main+0x80>
lea    0xdf8(%rip),%rdi
jmp    11d0 <main+0x80>
cs nopw 0x0(%rax,%rax,1)
mov    %r13,%rdi
cmp    %ebp,%eax
je     11d0 <main+0x80>
jmp    11d5 <main+0x85>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdd7(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [25 x i8] c"Usage: hoppity <in.txt>\0A\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [5 x i8] c"Hop\0A\00"
@.str.4 = [9 x i8] c"Hoppity\0A\00"
@.str.5 = [8 x i8] c"Hophop\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %8
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 1
br i1 %14, label %15, label %18
15: ; preds = %2
%16 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %2
%19 = load i32*, i32** %8
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %18
%25 = load i32*, i32** %8
%26 = call i32 @fscanf(i32* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %6)
%27 = load i32*, i32** %8
%28 = call i32 @fclose(i32* %27)
store i32 1, i32* %7
br label %29
29: ; preds = %55, %24
%30 = load i32, i32* %7
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
%33 = icmp slt i32 %30, %32
br i1 %33, label %34, label %58
34: ; preds = %29
%35 = load i32, i32* %7
%36 = srem i32 %35, 3
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %47
38: ; preds = %34
%39 = load i32, i32* %7
%40 = srem i32 %39, 5
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %38
%43 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %46
44: ; preds = %38
%45 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
br label %46
46: ; preds = %44, %42
br label %54
47: ; preds = %34
%48 = load i32, i32* %7
%49 = srem i32 %48, 5
%50 = icmp eq i32 %49, 0
br i1 %50, label %51, label %53
51: ; preds = %47
%52 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
br label %53
53: ; preds = %51, %47
br label %54
54: ; preds = %53, %46
br label %55
55: ; preds = %54
%56 = load i32, i32* %7
%57 = add nsw i32 %56, 1
store i32 %57, i32* %7
br label %29
58: ; preds = %29
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@str = [7 x i8] c"Hophop\00"
@str.6 = [8 x i8] c"Hoppity\00"
@str.7 = [4 x i8] c"Hop\00"
@str.9 = [24 x i8] c"Usage: hoppity <in.txt>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp slt i32 %0, 1
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.9, i64 0, i64 0))
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %2
%13 = icmp eq i32* %7, null
br i1 %13, label %14, label %17
14: ; preds = %12
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.9, i64 0, i64 0))
%16 = tail call i32 @exit(i32 1)
unreachable
17: ; preds = %12
%18 = call i32 @fscanf(i32* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%19 = call i32 @fclose(i32* %7)
%20 = load i32, i32* %3
%21 = icmp slt i32 %20, 1
br i1 %21, label %38, label %22
22: ; preds = %17, %34
%23 = phi i32 [ %35, %34 ], [ 1, %17 ]
%24 = urem i32 %23, 3
%25 = icmp eq i32 %24, 0
%26 = urem i32 %23, 5
%27 = icmp eq i32 %26, 0
br i1 %25, label %28, label %30
28: ; preds = %22
%29 = select i1 %27, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @str.7, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @str.6, i64 0, i64 0)
br label %31
30: ; preds = %22
br i1 %27, label %31, label %34
31: ; preds = %30, %28
%32 = phi i8* [ %29, %28 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0), %30 ]
%33 = call i32 @puts(i8* dereferenceable(1) %32)
br label %34
34: ; preds = %31, %30
%35 = add nuw nsw i32 %23, 1
%36 = load i32, i32* %3
%37 = icmp slt i32 %23, %36
br i1 %37, label %22, label %38
38: ; preds = %34, %17
ret i32 0
}