#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 /*<<< orphan*/ scanf(char *, int *, int *, int *);
int main() {
  int e, f, c;
  scanf("%d %d %d", &e, &f, &c);
  int sum = 0;
  e += f;
  while (e >= c) {
    int new_sodas = e / c, remaining_empty = e % c;
    sum += new_sodas;
    e = new_sodas + remaining_empty;
  }
  printf("%d\n", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1040 <scanf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0xc(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jl     118e <main+0x6e>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    1157 <main+0x37>
mov    -0x14(%rbp),%esi
lea    0xe71(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xed5(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x14(%rsp),%rdx
lea    0x10(%rsp),%rcx
call   1040 <scanf@plt>
mov    0xc(%rsp),%edx
add    0x14(%rsp),%edx
mov    0x10(%rsp),%ecx
xor    %esi,%esi
cmp    %ecx,%edx
jl     116d <main+0x4d>
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %edx,%eax
cltd
idiv   %ecx
add    %eax,%esi
add    %eax,%edx
cmp    %ecx,%edx
jge    1160 <main+0x40>
mov    %edx,0xc(%rsp)
lea    0xe91(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
@.str = [9 x i8] c"%d %d %d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
%8 = load i32, i32* %2
%9 = load i32, i32* %1
%10 = add nsw i32 %9, %8
%11 = load i32, i32* %3
%12 = icmp slt i32 %10, %11
br i1 %12, label %21, label %13
13: ; preds = %0, %13
%14 = phi i32 [ %18, %13 ], [ 0, %0 ]
%15 = phi i32 [ %19, %13 ], [ %10, %0 ]
%16 = sdiv i32 %15, %11
%17 = srem i32 %15, %11
%18 = add nsw i32 %16, %14
%19 = add nsw i32 %17, %16
%20 = icmp slt i32 %19, %11
br i1 %20, label %21, label %13
21: ; preds = %13, %0
%22 = phi i32 [ %10, %0 ], [ %19, %13 ]
%23 = phi i32 [ 0, %0 ], [ %18, %13 ]
store i32 %22, i32* %1
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %23)
ret i32 0
}