#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*/ fatalx(char *);
long random();
void pick2(int n, int *k1, int *k2) {
  long l1, l2;
  ;
  if (n < 2)
    fatalx("bad pick2 call\n");
  for (;;) {
    l1 = random();
    l2 = random();
    l1 = l1 % n;
    l2 = l2 % n;
    if (l1 != l2)
      break;
  }
  *k1 = l1;
  *k2 = l2;
}


x86 assembly (clang, -O0):
<pick2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x2,-0x4(%rbp)
jge    1149 <pick2+0x29>
lea    0xebc(%rip),%rdi
call   1030 <fatalx@plt>
jmp    114e <pick2+0x2e>
mov    $0x0,%al
call   1040 <random@plt>
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1040 <random@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x4(%rbp),%rcx
cqto
idiv   %rcx
mov    %rdx,-0x20(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x4(%rbp),%rcx
cqto
idiv   %rcx
mov    %rdx,-0x28(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
je     1199 <pick2+0x79>
jmp    119e <pick2+0x7e>
jmp    114e <pick2+0x2e>
mov    -0x20(%rbp),%rax
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pick2>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %edi,%r12d
cmp    $0x1,%edi
jg     1142 <pick2+0x22>
lea    0xec3(%rip),%rdi
call   1030 <fatalx@plt>
movslq %r12d,%rbp
jmp    115d <pick2+0x3d>
nopw   0x0(%rax,%rax,1)
mov    %rsi,%rax
cqto
idiv   %rbp
cmp    %rdx,%rcx
jne    11b1 <pick2+0x91>
xor    %eax,%eax
call   1040 <random@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1040 <random@plt>
mov    %rax,%rsi
mov    %rbx,%rax
or     %rbp,%rax
shr    $0x20,%rax
je     1190 <pick2+0x70>
mov    %rbx,%rax
cqto
idiv   %rbp
mov    %rdx,%rcx
jmp    1199 <pick2+0x79>
nopw   0x0(%rax,%rax,1)
mov    %ebx,%eax
xor    %edx,%edx
div    %r12d
mov    %edx,%ecx
mov    %rsi,%rax
or     %rbp,%rax
shr    $0x20,%rax
jne    1150 <pick2+0x30>
mov    %esi,%eax
xor    %edx,%edx
div    %r12d
cmp    %rdx,%rcx
je     115d <pick2+0x3d>
mov    %ecx,(%r15)
mov    %edx,(%r14)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"bad pick2 call\0A\00"
define void @pick2(i32 %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i64
%8 = alloca i64
store i32 %0, i32* %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %13
11: ; preds = %3
%12 = call i32 @fatalx(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %3
br label %14
14: ; preds = %29, %13
%15 = call i64 (...) @random()
store i64 %15, i64* %7
%16 = call i64 (...) @random()
store i64 %16, i64* %8
%17 = load i64, i64* %7
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = srem i64 %17, %19
store i64 %20, i64* %7
%21 = load i64, i64* %8
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = srem i64 %21, %23
store i64 %24, i64* %8
%25 = load i64, i64* %7
%26 = load i64, i64* %8
%27 = icmp ne i64 %25, %26
br i1 %27, label %28, label %29
28: ; preds = %14
br label %30
29: ; preds = %14
br label %14
30: ; preds = %28
%31 = load i64, i64* %7
%32 = trunc i64 %31 to i32
%33 = load i32*, i32** %5
store i32 %32, i32* %33
%34 = load i64, i64* %8
%35 = trunc i64 %34 to i32
%36 = load i32*, i32** %6
store i32 %35, i32* %36
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"bad pick2 call\0A\00"
define void @pick2(i32 %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2) {
%4 = icmp slt i32 %0, 2
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 @fatalx(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %5, %3
%8 = sext i32 %0 to i64
br label %9
9: ; preds = %9, %7
%10 = tail call i64 (...) @random()
%11 = tail call i64 (...) @random()
%12 = srem i64 %10, %8
%13 = srem i64 %11, %8
%14 = icmp eq i64 %12, %13
br i1 %14, label %9, label %15
15: ; preds = %9
%16 = trunc i64 %12 to i32
store i32 %16, i32* %1
%17 = trunc i64 %13 to i32
store i32 %17, i32* %2
ret void
}