#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 main() {
  int i, e, f, c, n, s, test;
  scanf("%d", &test);
  for (i = 1; i <= test; i++) {
    scanf("%d %d %d", &e, &f, &c);
    n = e + f;
    s = 0;
    while (n >= c) {
      n = (n - c) + 1;
      s++;
    }
    printf("%d\n", s);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xed0(%rip),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x20(%rbp),%eax
jg     11c1 <main+0xa1>
lea    0xea5(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x14(%rbp),%rcx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jl     11a4 <main+0x84>
mov    -0x18(%rbp),%eax
sub    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    117e <main+0x5e>
mov    -0x1c(%rbp),%esi
lea    0xe5b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1148 <main+0x28>
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
sub    $0x18,%rsp
lea    0xed1(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0x0,0x8(%rsp)
jle    11ce <main+0xae>
mov    $0x1,%r14d
lea    0x14(%rsp),%r15
lea    0x10(%rsp),%r12
lea    0xc(%rsp),%r13
lea    0xea1(%rip),%rbx
jmp    1188 <main+0x68>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
lea    0x1(%r14),%eax
cmp    0x8(%rsp),%r14d
mov    %eax,%r14d
jge    11ce <main+0xae>
xor    %ebp,%ebp
lea    0xe6f(%rip),%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x10(%rsp),%eax
add    0x14(%rsp),%eax
mov    0xc(%rsp),%ecx
cmp    %ecx,%eax
jl     1170 <main+0x50>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
sub    %ecx,%eax
add    $0x1,%eax
add    $0x1,%ebp
cmp    %ecx,%eax
jge    11c0 <main+0xa0>
jmp    1170 <main+0x50>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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