#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, int);
int rankWriteNoMore(FILE *fp, int start, int rank, int len) {
  for (int i = 0; i < len; i++) {
    fprintf(fp, "%d:%d ", start + i, rank == i + 1 ? 1 : 0);
  }
  return 1;
}


x86 assembly (clang, -O0):
<rankWriteNoMore>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1174 <rankWriteNoMore+0x64>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
add    -0x18(%rbp),%edx
mov    -0x10(%rbp),%esi
mov    -0x18(%rbp),%r8d
add    $0x1,%r8d
xor    %ecx,%ecx
mov    $0x1,%eax
cmp    %r8d,%esi
cmove  %eax,%ecx
lea    0xe9f(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    112c <rankWriteNoMore+0x1c>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rankWriteNoMore>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %ecx,%ecx
jle    1160 <rankWriteNoMore+0x50>
mov    %ecx,%r15d
mov    %edx,%ebp
mov    %esi,%r14d
mov    %rdi,%r13
add    $0xffffffff,%ebp
xor    %eax,%eax
lea    0xeca(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
lea    0x1(%rax),%ebx
lea    (%r14,%rax,1),%edx
xor    %ecx,%ecx
cmp    %eax,%ebp
sete   %cl
mov    %r13,%rdi
mov    %r12,%rsi
call   1030 <fprintf@plt>
mov    %ebx,%eax
cmp    %ebx,%r15d
jne    1140 <rankWriteNoMore+0x30>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [7 x i8] c"%d:%d \00"
define i32 @rankWriteNoMore(i32* nocapture %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp sgt i32 %3, 0
br i1 %5, label %7, label %6
6: ; preds = %7, %4
ret i32 1
7: ; preds = %4, %7
%8 = phi i32 [ %10, %7 ], [ 0, %4 ]
%9 = add nsw i32 %8, %1
%10 = add nuw nsw i32 %8, 1
%11 = icmp eq i32 %10, %2
%12 = zext i1 %11 to i32
%13 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %12)
%14 = icmp eq i32 %10, %3
br i1 %14, label %6, label %7
}