#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 */
struct atrf_dsc {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, int);
scalar_t__ xfer_one(struct atrf_dsc *, struct atrf_dsc *);
void xfer(struct atrf_dsc *tx, struct atrf_dsc *rx, int packets) {
  int got = 0;
  int i;
  for (i = 0; i != packets; i++)
    got += xfer_one(tx, rx);
  printf("%d/%d\n", got, packets);
}


x86 assembly (clang, -O0):
<xfer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
je     1175 <xfer+0x55>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <xfer_one@plt>
mov    %rax,%rcx
movslq -0x18(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1141 <xfer+0x21>
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xe7e(%rip),%rdi
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xfer>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r14d
test   %edx,%edx
je     1154 <xfer+0x34>
mov    %rsi,%r15
mov    %rdi,%r12
xor    %ebp,%ebp
mov    %r14d,%ebx
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r15,%rsi
call   1030 <xfer_one@plt>
add    %eax,%ebp
add    $0xffffffff,%ebx
jne    1140 <xfer+0x20>
jmp    1156 <xfer+0x36>
xor    %ebp,%ebp
lea    0xea3(%rip),%rdi
mov    %ebp,%esi
mov    %r14d,%edx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
%struct.atrf_dsc = type { i32 }
@.str = [7 x i8] c"%d/%d\0A\00"
define void @xfer(%struct.atrf_dsc* %0, %struct.atrf_dsc* %1, i32 %2) {
%4 = alloca %struct.atrf_dsc*
%5 = alloca %struct.atrf_dsc*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store %struct.atrf_dsc* %0, %struct.atrf_dsc** %4
store %struct.atrf_dsc* %1, %struct.atrf_dsc** %5
store i32 %2, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
br label %9
9: ; preds = %21, %3
%10 = load i32, i32* %8
%11 = load i32, i32* %6
%12 = icmp ne i32 %10, %11
br i1 %12, label %13, label %24
13: ; preds = %9
%14 = load %struct.atrf_dsc*, %struct.atrf_dsc** %4
%15 = load %struct.atrf_dsc*, %struct.atrf_dsc** %5
%16 = call i64 @xfer_one(%struct.atrf_dsc* %14, %struct.atrf_dsc* %15)
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = add nsw i64 %18, %16
%20 = trunc i64 %19 to i32
store i32 %20, i32* %7
br label %21
21: ; preds = %13
%22 = load i32, i32* %8
%23 = add nsw i32 %22, 1
store i32 %23, i32* %8
br label %9
24: ; preds = %9
%25 = load i32, i32* %7
%26 = load i32, i32* %6
%27 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %25, i32 %26)
ret void
}

LLVM IR (-O2):
%struct.atrf_dsc = type { i32 }
@.str = [7 x i8] c"%d/%d\0A\00"
define void @xfer(%struct.atrf_dsc* %0, %struct.atrf_dsc* %1, i32 %2) {
%4 = icmp eq i32 %2, 0
br i1 %4, label %13, label %5
5: ; preds = %3, %5
%6 = phi i32 [ %11, %5 ], [ 0, %3 ]
%7 = phi i32 [ %10, %5 ], [ 0, %3 ]
%8 = tail call i64 @xfer_one(%struct.atrf_dsc* %0, %struct.atrf_dsc* %1)
%9 = trunc i64 %8 to i32
%10 = add i32 %7, %9
%11 = add nuw nsw i32 %6, 1
%12 = icmp eq i32 %11, %2
br i1 %12, label %13, label %5
13: ; preds = %5, %3
%14 = phi i32 [ 0, %3 ], [ %10, %5 ]
%15 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %14, i32 %2)
ret void
}