#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 /*<<< orphan*/ printf(char *, int, int);
int main(void) {
  int friends, n;
  n = 0;
  friends = 5;
  printf("Week%2d, Prof.Rabnud has %d friends.\n", n, friends);
  while (friends <= 150) {
    n++;
    friends = 2 * (friends - n);
    printf("Week%2d, Prof.Rabnud has %d friends.\n", n, friends);
  }
  printf("Prof.Rabnud has a number of friends more than Dunbar's number (%d in "
         "this program) in week %d!\n",
         150, n);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x5,-0x8(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xec6(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x96,-0x8(%rbp)
jg     1178 <main+0x68>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
sub    -0xc(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe92(%rip),%rdi
call   1030 <printf@plt>
jmp    113f <main+0x2f>
mov    -0xc(%rbp),%edx
lea    0xea4(%rip),%rdi
mov    $0x96,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
lea    0xee1(%rip),%r14
xor    %ebx,%ebx
mov    $0x5,%r12d
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x5,%edx
call   1030 <printf@plt>
mov    $0x1,%ebp
nopl   0x0(%rax,%rax,1)
lea    (%r12,%rbx,1),%eax
lea    (%rax,%rax,1),%r15d
add    $0xfffffffe,%r15d
mov    %r14,%rdi
mov    %ebp,%esi
mov    %r15d,%edx
call   1030 <printf@plt>
add    $0x1,%ebp
mov    %ebx,%eax
add    $0xffffffff,%ebx
add    %r12d,%eax
add    $0xffffffff,%eax
mov    %r15d,%r12d
cmp    $0x4c,%eax
jl     1140 <main+0x30>
neg    %ebx
lea    0xeae(%rip),%rdi
mov    $0x96,%esi
mov    %ebx,%edx
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [38 x i8] c"Week%2d, Prof.Rabnud has %d friends.\0A\00"
@.str.1 = [96 x i8] c"Prof.Rabnud has a number of friends more than Dunbar's number (%d in this program) in week %d!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 5, i32* %2
%4 = load i32, i32* %3
%5 = load i32, i32* %2
%6 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %5)
br label %7
7: ; preds = %10, %0
%8 = load i32, i32* %2
%9 = icmp sle i32 %8, 150
br i1 %9, label %10, label %20
10: ; preds = %7
%11 = load i32, i32* %3
%12 = add nsw i32 %11, 1
store i32 %12, i32* %3
%13 = load i32, i32* %2
%14 = load i32, i32* %3
%15 = sub nsw i32 %13, %14
%16 = mul nsw i32 2, %15
store i32 %16, i32* %2
%17 = load i32, i32* %3
%18 = load i32, i32* %2
%19 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %18)
br label %7
20: ; preds = %7
%21 = load i32, i32* %3
%22 = call i32 @printf(i8* getelementptr inbounds ([96 x i8], [96 x i8]* @.str.1, i64 0, i64 0), i32 150, i32 %21)
ret i32 0
}

LLVM IR (-O2):
@.str = [38 x i8] c"Week%2d, Prof.Rabnud has %d friends.\0A\00"
@.str.1 = [96 x i8] c"Prof.Rabnud has a number of friends more than Dunbar's number (%d in this program) in week %d!\0A\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 0, i32 5)
br label %2
2: ; preds = %0, %2
%3 = phi i32 [ 0, %0 ], [ %5, %2 ]
%4 = phi i32 [ 5, %0 ], [ %7, %2 ]
%5 = add nuw nsw i32 %3, 1
%6 = sub nsw i32 %4, %5
%7 = shl nsw i32 %6, 1
%8 = tail call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %7)
%9 = icmp slt i32 %6, 76
br i1 %9, label %2, label %10
10: ; preds = %2
%11 = tail call i32 @printf(i8* getelementptr inbounds ([96 x i8], [96 x i8]* @.str.1, i64 0, i64 0), i32 150, i32 %5)
ret i32 0
}