#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*/ move_char(int *, char **);
int /*<<< orphan*/ printf(char *);
scalar_t__ strlen(char *);
char *permute(char **string, int *i) {
  if (*i >= (int)strlen(*string))
    *i = 0;
  if (!move_char(i, string))
    printf("Could not move char.\n");
  return *string;
}


x86 assembly (clang, -O0):
<permute>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
jl     116d <permute+0x3d>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1050 <move_char@plt>
cmp    $0x0,%eax
jne    118f <permute+0x5f>
lea    0xe76(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<permute>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
mov    (%rsi),%ebp
mov    (%rdi),%rdi
call   1040 <strlen@plt>
cmp    %eax,%ebp
jl     114e <permute+0x1e>
movl   $0x0,(%rbx)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <move_char@plt>
test   %eax,%eax
jne    1169 <permute+0x39>
lea    0xe9c(%rip),%rdi
call   1030 <puts@plt>
mov    (%r14),%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Could not move char.\0A\00"
define i8* @permute(i8** %0, i32* %1) {
%3 = alloca i8**
%4 = alloca i32*
store i8** %0, i8*** %3
store i32* %1, i32** %4
%5 = load i32*, i32** %4
%6 = load i32, i32* %5
%7 = load i8**, i8*** %3
%8 = load i8*, i8** %7
%9 = call i64 @strlen(i8* %8)
%10 = trunc i64 %9 to i32
%11 = icmp sge i32 %6, %10
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = load i32*, i32** %4
store i32 0, i32* %13
br label %14
14: ; preds = %12, %2
%15 = load i32*, i32** %4
%16 = load i8**, i8*** %3
%17 = call i32 @move_char(i32* %15, i8** %16)
%18 = icmp ne i32 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %14
%20 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %21
21: ; preds = %19, %14
%22 = load i8**, i8*** %3
%23 = load i8*, i8** %22
ret i8* %23
}

LLVM IR (-O2):
@str = [21 x i8] c"Could not move char.\00"
define i8* @permute(i8** %0, i32* %1) {
%3 = load i32, i32* %1
%4 = load i8*, i8** %0
%5 = tail call i64 @strlen(i8* dereferenceable(1) %4)
%6 = trunc i64 %5 to i32
%7 = icmp slt i32 %3, %6
br i1 %7, label %9, label %8
8: ; preds = %2
store i32 0, i32* %1
br label %9
9: ; preds = %8, %2
%10 = tail call i32 @move_char(i32* %1, i8** %0)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
br label %14
14: ; preds = %12, %9
%15 = load i8*, i8** %0
ret i8* %15
}