#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 /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  const int DAYS_PER_WEEK = 7;
  int days;
  printf("Enter the number of days:\n");
  scanf("%d", &days);
  while (days > 0) {
    printf("%d days are %d weeks, %d days.\n", days, days / DAYS_PER_WEEK,
           days % DAYS_PER_WEEK);
    printf("Enter the next number:\n");
    scanf("%d", &days);
  }
  printf("Done!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x7,-0x8(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed0(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0xc(%rbp)
jle    11b0 <main+0x90>
mov    -0xc(%rbp),%esi
mov    -0xc(%rbp),%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
mov    -0x10(%rbp),%edx
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe79(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
jmp    1154 <main+0x34>
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xee4(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb5(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
jle    11ca <main+0x9a>
lea    0xe9f(%rip),%r14
lea    0xed8(%rip),%r15
lea    0xe8e(%rip),%r12
lea    0x4(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
mov    %esi,%eax
imul   $0x24924925,%rax,%rax
shr    $0x20,%rax
mov    %esi,%edx
sub    %eax,%edx
shr    %edx
add    %eax,%edx
shr    $0x2,%edx
lea    0x0(,%rdx,8),%eax
mov    %edx,%ecx
sub    %eax,%ecx
add    %esi,%ecx
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
jg     1180 <main+0x50>
lea    0xe6c(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Enter the number of days:\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [32 x i8] c"%d days are %d weeks, %d days.\0A\00"
@.str.3 = [24 x i8] c"Enter the next number:\0A\00"
@.str.4 = [7 x i8] c"Done!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 7, i32* %2
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
br label %6
6: ; preds = %9, %0
%7 = load i32, i32* %3
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %18
9: ; preds = %6
%10 = load i32, i32* %3
%11 = load i32, i32* %3
%12 = sdiv i32 %11, 7
%13 = load i32, i32* %3
%14 = srem i32 %13, 7
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %10, i32 %12, i32 %14)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
br label %6
18: ; preds = %6
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [32 x i8] c"%d days are %d weeks, %d days.\0A\00"
@str = [26 x i8] c"Enter the number of days:\00"
@str.5 = [6 x i8] c"Done!\00"
@str.6 = [23 x i8] c"Enter the next number:\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %16
7: ; preds = %0, %7
%8 = phi i32 [ %14, %7 ], [ %5, %0 ]
%9 = udiv i32 %8, 7
%10 = urem i32 %8, 7
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %8, i32 %9, i32 %10)
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.6, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%14 = load i32, i32* %1
%15 = icmp sgt i32 %14, 0
br i1 %15, label %7, label %16
16: ; preds = %7, %0
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.5, i64 0, i64 0))
ret i32 0
}