#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 uint32_t;

/* Variables and functions */
char *calloc(int, int);
int /*<<< orphan*/ permute(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int main(int argc, char **argv) {
  (void)argc;
  (void)argv;
  char *a = calloc(11, sizeof(char));
  strncpy(a, "0123456789", 11);
  for (uint32_t i = 0; i < 1000000 - 1; i++) {
    permute(a);
  }
  printf("%s\n", a);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0xb,%edi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe8c(%rip),%rsi
mov    $0xb,%edx
call   1030 <strncpy@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0xf423f,-0x1c(%rbp)
jge    11a9 <main+0x69>
mov    -0x18(%rbp),%rdi
call   1040 <permute@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1185 <main+0x45>
mov    -0x18(%rbp),%rsi
lea    0xe57(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    $0xb,%edi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,%rbx
lea    0xea4(%rip),%rsi
mov    %rax,%rdi
mov    $0xb,%edx
call   1030 <strncpy@plt>
mov    $0xf423f,%ebp
xchg   %ax,%ax
mov    %rbx,%rdi
call   1040 <permute@plt>
add    $0xffffffff,%ebp
jne    1170 <main+0x30>
lea    0xe87(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"0123456789\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = load i8**, i8*** %5
%10 = call i8* @calloc(i32 11, i32 1)
store i8* %10, i8** %6
%11 = load i8*, i8** %6
%12 = call i32 @strncpy(i8* %11, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 11)
store i32 0, i32* %7
br label %13
13: ; preds = %19, %2
%14 = load i32, i32* %7
%15 = icmp slt i32 %14, 999999
br i1 %15, label %16, label %22
16: ; preds = %13
%17 = load i8*, i8** %6
%18 = call i32 @permute(i8* %17)
br label %19
19: ; preds = %16
%20 = load i32, i32* %7
%21 = add nsw i32 %20, 1
store i32 %21, i32* %7
br label %13
22: ; preds = %13
%23 = load i8*, i8** %6
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %23)
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"0123456789\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call dereferenceable_or_null(11) i8* @calloc(i32 11, i32 1)
%4 = tail call i32 @strncpy(i8* %3, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 11)
br label %7
5: ; preds = %7
%6 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %3)
ret i32 0
7: ; preds = %2, %7
%8 = phi i32 [ 0, %2 ], [ %10, %7 ]
%9 = tail call i32 @permute(i8* %3)
%10 = add nuw nsw i32 %8, 1
%11 = icmp eq i32 %10, 999999
br i1 %11, label %5, label %7
}