#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int gen_comb_norep_lex_init(unsigned char *, unsigned char, unsigned char);
int gen_comb_norep_lex_next(unsigned char *, unsigned char, unsigned char);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, unsigned int, ...);
int /*<<< orphan*/ stderr;
int main(void) {
  unsigned char n = 5;
  unsigned char k = 3;
  unsigned char *vector = NULL;
  int gen_result;
  unsigned int set_counter;
  int x;
  vector = (unsigned char *)malloc(sizeof(unsigned char) * k);
  if (vector == NULL) {
    fprintf(stderr, "error: insufficient memory\n");
    exit(EXIT_FAILURE);
  }
  set_counter = 0;
  printf("comb_norep_lex(%u, %u)\n", n, k);
  gen_result = gen_comb_norep_lex_init(vector, n, k);
  if (gen_result == 3) {
    fprintf(stderr, "error: couldn't initialize\n");
    return (EXIT_FAILURE);
  }
  if (gen_result == 2) {
    set_counter++;
    printf("{} (%u)\n", set_counter);
  }
  while (gen_result == 0) {
    set_counter++;
    for (x = 0; x < k; x++)
      printf("%u ", vector[x]);
    printf("(%u)\n", set_counter);
    gen_result = gen_comb_norep_lex_next(vector, n, k);
  }
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x5,-0x5(%rbp)
movb   $0x3,-0x6(%rbp)
movq   $0x0,-0x10(%rbp)
movzbl -0x6(%rbp),%eax
shl    $0x0,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11c0 <main+0x60>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
lea    0xe53(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
movl   $0x0,-0x18(%rbp)
movzbl -0x5(%rbp),%esi
movzbl -0x6(%rbp),%edx
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x5(%rbp),%al
movzbl %al,%esi
movzbl -0x6(%rbp),%edx
call   1040 <gen_comb_norep_lex_init@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jne    1223 <main+0xc3>
mov    0x2ddc(%rip),%rax
mov    (%rax),%edi
lea    0xe27(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2dbf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12d5 <main+0x175>
cmpl   $0x2,-0x14(%rbp)
jne    1247 <main+0xe7>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    124c <main+0xec>
cmpl   $0x0,-0x14(%rbp)
jne    12c9 <main+0x169>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
movzbl -0x6(%rbp),%ecx
cmp    %ecx,%eax
jge    129d <main+0x13d>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xdd1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1266 <main+0x106>
mov    -0x18(%rbp),%esi
lea    0xdac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x5(%rbp),%al
movzbl %al,%esi
movzbl -0x6(%rbp),%edx
call   1050 <gen_comb_norep_lex_next@plt>
mov    %eax,-0x14(%rbp)
jmp    124c <main+0xec>
mov    0x2d00(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    $0x3,%edi
call   1070 <malloc@plt>
test   %rax,%rax
je     126b <main+0x10b>
mov    %rax,%rbx
lea    0xe97(%rip),%rdi
mov    $0x5,%esi
mov    $0x3,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
mov    $0x3,%edx
call   1040 <gen_comb_norep_lex_init@plt>
mov    0x2e21(%rip),%r12
test   %eax,%eax
je     11f4 <main+0x94>
cmp    $0x2,%eax
je     11df <main+0x7f>
cmp    $0x3,%eax
jne    125e <main+0xfe>
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
lea    0xe63(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2dfb(%rip),%r12
jmp    125e <main+0xfe>
lea    0xe6a(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    125e <main+0xfe>
mov    $0x1,%ebp
lea    0xe59(%rip),%r14
lea    0xe4c(%rip),%r15
nopw   0x0(%rax,%rax,1)
movzbl (%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movzbl 0x1(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movzbl 0x2(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
mov    $0x3,%edx
call   1050 <gen_comb_norep_lex_next@plt>
add    $0x1,%ebp
test   %eax,%eax
je     1210 <main+0xb0>
mov    (%r12),%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d6e(%rip),%rax
mov    (%rax),%edi
lea    0xd85(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2d51(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [28 x i8] c"error: insufficient memory\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [24 x i8] c"comb_norep_lex(%u, %u)\0A\00"
@.str.2 = [28 x i8] c"error: couldn't initialize\0A\00"
@.str.3 = [9 x i8] c"{} (%u)\0A\00"
@.str.4 = [4 x i8] c"%u \00"
@.str.5 = [6 x i8] c"(%u)\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i8
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i8 5, i8* %2
store i8 3, i8* %3
store i8* null, i8** %4
%8 = load i8, i8* %3
%9 = zext i8 %8 to i64
%10 = mul i64 1, %9
%11 = trunc i64 %10 to i32
%12 = call i64 @malloc(i32 %11)
%13 = inttoptr i64 %12 to i8*
store i8* %13, i8** %4
%14 = load i8*, i8** %4
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %21
16: ; preds = %0
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%19 = load i32, i32* @EXIT_FAILURE
%20 = call i32 @exit(i32 %19)
unreachable
21: ; preds = %0
store i32 0, i32* %6
%22 = load i8, i8* %2
%23 = zext i8 %22 to i32
%24 = load i8, i8* %3
%25 = zext i8 %24 to i32
%26 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %23, i32 %25)
%27 = load i8*, i8** %4
%28 = load i8, i8* %2
%29 = load i8, i8* %3
%30 = call i32 @gen_comb_norep_lex_init(i8* %27, i8 zeroext %28, i8 zeroext %29)
store i32 %30, i32* %5
%31 = load i32, i32* %5
%32 = icmp eq i32 %31, 3
br i1 %32, label %33, label %37
33: ; preds = %21
%34 = load i32, i32* @stderr
%35 = call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%36 = load i32, i32* @EXIT_FAILURE
store i32 %36, i32* %1
br label %77
37: ; preds = %21
%38 = load i32, i32* %5
%39 = icmp eq i32 %38, 2
br i1 %39, label %40, label %45
40: ; preds = %37
%41 = load i32, i32* %6
%42 = add i32 %41, 1
store i32 %42, i32* %6
%43 = load i32, i32* %6
%44 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %43)
br label %45
45: ; preds = %40, %37
br label %46
46: ; preds = %68, %45
%47 = load i32, i32* %5
%48 = icmp eq i32 %47, 0
br i1 %48, label %49, label %75
49: ; preds = %46
%50 = load i32, i32* %6
%51 = add i32 %50, 1
store i32 %51, i32* %6
store i32 0, i32* %7
br label %52
52: ; preds = %65, %49
%53 = load i32, i32* %7
%54 = load i8, i8* %3
%55 = zext i8 %54 to i32
%56 = icmp slt i32 %53, %55
br i1 %56, label %57, label %68
57: ; preds = %52
%58 = load i8*, i8** %4
%59 = load i32, i32* %7
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8, i8* %58, i64 %60
%62 = load i8, i8* %61
%63 = zext i8 %62 to i32
%64 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %63)
br label %65
65: ; preds = %57
%66 = load i32, i32* %7
%67 = add nsw i32 %66, 1
store i32 %67, i32* %7
br label %52
68: ; preds = %52
%69 = load i32, i32* %6
%70 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32 %69)
%71 = load i8*, i8** %4
%72 = load i8, i8* %2
%73 = load i8, i8* %3
%74 = call i32 @gen_comb_norep_lex_next(i8* %71, i8 zeroext %72, i8 zeroext %73)
store i32 %74, i32* %5
br label %46
75: ; preds = %46
%76 = load i32, i32* @EXIT_SUCCESS
store i32 %76, i32* %1
br label %77
77: ; preds = %75, %33
%78 = load i32, i32* %1
ret i32 %78
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [28 x i8] c"error: insufficient memory\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [24 x i8] c"comb_norep_lex(%u, %u)\0A\00"
@.str.2 = [28 x i8] c"error: couldn't initialize\0A\00"
@.str.3 = [9 x i8] c"{} (%u)\0A\00"
@.str.4 = [4 x i8] c"%u \00"
@.str.5 = [6 x i8] c"(%u)\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = tail call i64 @malloc(i32 3)
%2 = inttoptr i64 %1 to i8*
%3 = icmp eq i64 %1, 0
br i1 %3, label %4, label %9
4: ; preds = %0
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @EXIT_FAILURE
%8 = tail call i32 @exit(i32 %7)
unreachable
9: ; preds = %0
%10 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 5, i32 3)
%11 = tail call i32 @gen_comb_norep_lex_init(i8* %2, i8 zeroext 5, i8 zeroext 3)
switch i32 %11, label %35 [
i32 3, label %12
i32 2, label %15
i32 0, label %17
]
12: ; preds = %9
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %35
15: ; preds = %9
%16 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 1)
br label %35
17: ; preds = %9
%18 = getelementptr inbounds i8, i8* %2, i64 1
%19 = getelementptr inbounds i8, i8* %2, i64 2
br label %20
20: ; preds = %17, %20
%21 = phi i32 [ %31, %20 ], [ 0, %17 ]
%22 = load i8, i8* %2
%23 = zext i8 %22 to i32
%24 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %23)
%25 = load i8, i8* %18
%26 = zext i8 %25 to i32
%27 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %26)
%28 = load i8, i8* %19
%29 = zext i8 %28 to i32
%30 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %29)
%31 = add i32 %21, 1
%32 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32 %31)
%33 = tail call i32 @gen_comb_norep_lex_next(i8* %2, i8 zeroext 5, i8 zeroext 3)
%34 = icmp eq i32 %33, 0
br i1 %34, label %20, label %35
35: ; preds = %20, %9, %15, %12
%36 = phi i32* [ @EXIT_FAILURE, %12 ], [ @EXIT_SUCCESS, %15 ], [ @EXIT_SUCCESS, %9 ], [ @EXIT_SUCCESS, %20 ]
%37 = load i32, i32* %36
ret i32 %37
}