#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*/ fscanf(int /*<<< orphan*/ *, char *, char *);
int setPages(FILE *input) {
  int pageNum = 0;
  int count = 0;
  char word[12];
  fscanf(input, "%s", word);
  while (word[0] != '-') {
    count++;
    fscanf(input, "%s", word);
  }
  pageNum = count / (6 * 3);
  if (count % (6 * 3) != 0)
    pageNum++;
  return pageNum;
}


x86 assembly (clang, -O0):
<setPages>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x1c(%rbp),%rdx
lea    0xec7(%rip),%rsi
call   1030 <fscanf@plt>
movsbl -0x1c(%rbp),%eax
cmp    $0x2d,%eax
je     116d <setPages+0x5d>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x1c(%rbp),%rdx
lea    0xe9d(%rip),%rsi
call   1030 <fscanf@plt>
jmp    113e <setPages+0x2e>
mov    -0x10(%rbp),%eax
mov    $0x12,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x12,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1198 <setPages+0x88>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setPages>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
lea    0xedc(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1030 <fscanf@plt>
xor    %ebp,%ebp
cmpb   $0x2d,0xc(%rsp)
je     1168 <setPages+0x58>
xor    %ebp,%ebp
lea    0xec0(%rip),%r14
lea    0xc(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%ebp
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1030 <fscanf@plt>
cmpb   $0x2d,0xc(%rsp)
jne    1150 <setPages+0x40>
mov    %ebp,%eax
imul   $0x38e38e39,%rax,%rax
imul   $0x38e38e39,%ebp,%ecx
ror    %ecx
shr    $0x22,%rax
cmp    $0xe38e38f,%ecx
sbb    $0xffffffff,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define i32 @setPages(i32* nocapture %0) {
%2 = alloca [12 x i8]
%3 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%4 = call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%5 = load i8, i8* %3
%6 = icmp eq i8 %5, 45
br i1 %6, label %13, label %7
7: ; preds = %1, %7
%8 = phi i32 [ %9, %7 ], [ 0, %1 ]
%9 = add nuw nsw i32 %8, 1
%10 = call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%11 = load i8, i8* %3
%12 = icmp eq i8 %11, 45
br i1 %12, label %13, label %7
13: ; preds = %7, %1
%14 = phi i32 [ 0, %1 ], [ %9, %7 ]
%15 = udiv i32 %14, 18
%16 = urem i32 %14, 18
%17 = icmp ne i32 %16, 0
%18 = zext i1 %17 to i32
%19 = add nuw nsw i32 %15, %18
ret i32 %19
}