#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*/ chunk_reverse(char *, int);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
char *test_one_chunk_reverse(char *msg, char *str, int n, char *rev) {
  char temp[strlen(str)];
  strcpy(temp, str);
  chunk_reverse(temp, n);
  do {
    int result = temp != NULL;
    printf("%s", (result ? "+" : "-"));
    if (!result)
      return msg;
  } while (0);
  do {
    int result = strlen(temp) > 0;
    printf("%s", (result ? "+" : "-"));
    if (!result)
      return msg;
  } while (0);
  do {
    int result = strcmp(temp, rev) == 0;
    printf("%s", (result ? "+" : "-"));
    if (!result)
      return msg;
  } while (0);
  return (0);
}


x86 assembly (clang, -O0):
<test_one_chunk_reverse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rcx
mov    %rcx,%rax
mov    %rsp,%rdx
mov    %rdx,-0x30(%rbp)
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x50(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x50(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1040 <chunk_reverse@plt>
mov    -0x50(%rbp),%rax
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%ecx
lea    0xe3d(%rip),%rsi
lea    0xe34(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0xe23(%rip),%rdi
call   1060 <printf@plt>
cmpl   $0x0,-0x3c(%rbp)
jne    1200 <test_one_chunk_reverse+0xb0>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
movl   $0x1,-0x40(%rbp)
jmp    12ef <test_one_chunk_reverse+0x19f>
jmp    1205 <test_one_chunk_reverse+0xb5>
jmp    120a <test_one_chunk_reverse+0xba>
jmp    120f <test_one_chunk_reverse+0xbf>
mov    -0x50(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x0,%rax
setg   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%ecx
lea    0xdd4(%rip),%rsi
lea    0xdcb(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0xdba(%rip),%rdi
call   1060 <printf@plt>
cmpl   $0x0,-0x44(%rbp)
jne    1269 <test_one_chunk_reverse+0x119>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
movl   $0x1,-0x40(%rbp)
jmp    12ef <test_one_chunk_reverse+0x19f>
jmp    126e <test_one_chunk_reverse+0x11e>
jmp    1273 <test_one_chunk_reverse+0x123>
jmp    1278 <test_one_chunk_reverse+0x128>
mov    -0x50(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%ecx
lea    0xd67(%rip),%rsi
lea    0xd5e(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0xd4d(%rip),%rdi
call   1060 <printf@plt>
cmpl   $0x0,-0x48(%rbp)
jne    12d6 <test_one_chunk_reverse+0x186>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
movl   $0x1,-0x40(%rbp)
jmp    12ef <test_one_chunk_reverse+0x19f>
jmp    12db <test_one_chunk_reverse+0x18b>
jmp    12e0 <test_one_chunk_reverse+0x190>
movq   $0x0,-0x8(%rbp)
movl   $0x1,-0x40(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    -0x8(%rbp),%rax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_one_chunk_reverse>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,-0x38(%rbp)
mov    %edx,%r12d
mov    %rsi,%r13
mov    %rdi,-0x30(%rbp)
mov    %rsi,%rdi
call   1050 <strlen@plt>
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
mov    %r13,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r12d,%esi
call   1040 <chunk_reverse@plt>
lea    0xe5b(%rip),%r14
lea    0xe57(%rip),%r15
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %rax,%r12
test   %rax,%rax
lea    0xe39(%rip),%r13
mov    %r13,%rsi
cmovg  %r15,%rsi
mov    %r14,%rdi
call   1060 <printf@plt>
test   %r12,%r12
jle    1216 <test_one_chunk_reverse+0xc6>
mov    %rbx,%rdi
mov    -0x38(%rbp),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
lea    0xe0d(%rip),%rcx
cmove  %rcx,%r13
lea    0xdff(%rip),%rdi
mov    -0x30(%rbp),%rbx
cmove  %rax,%rbx
mov    %r13,%rsi
call   1060 <printf@plt>
mov    %rbx,%rax
jmp    121a <test_one_chunk_reverse+0xca>
mov    -0x30(%rbp),%rax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [2 x i8] c"+\00"
@.str.2 = [2 x i8] c"-\00"
define i8* @test_one_chunk_reverse(i8* %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i8* %3, i8** %9
%16 = load i8*, i8** %7
%17 = call i64 @strlen(i8* %16)
%18 = call i8* @llvm.stacksave()
store i8* %18, i8** %10
%19 = alloca i8, i64 %17
store i64 %17, i64* %11
%20 = load i8*, i8** %7
%21 = call i32 @strcpy(i8* %19, i8* %20)
%22 = load i32, i32* %8
%23 = call i32 @chunk_reverse(i8* %19, i32 %22)
br label %24
24: ; preds = %4
%25 = icmp ne i8* %19, null
%26 = zext i1 %25 to i32
store i32 %26, i32* %12
%27 = load i32, i32* %12
%28 = icmp ne i32 %27, 0
%29 = zext i1 %28 to i64
%30 = select i1 %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
%31 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %30)
%32 = load i32, i32* %12
%33 = icmp ne i32 %32, 0
br i1 %33, label %36, label %34
34: ; preds = %24
%35 = load i8*, i8** %6
store i8* %35, i8** %5
store i32 1, i32* %13
br label %72
36: ; preds = %24
br label %37
37: ; preds = %36
br label %38
38: ; preds = %37
br label %39
39: ; preds = %38
%40 = call i64 @strlen(i8* %19)
%41 = icmp sgt i64 %40, 0
%42 = zext i1 %41 to i32
store i32 %42, i32* %14
%43 = load i32, i32* %14
%44 = icmp ne i32 %43, 0
%45 = zext i1 %44 to i64
%46 = select i1 %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
%47 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %46)
%48 = load i32, i32* %14
%49 = icmp ne i32 %48, 0
br i1 %49, label %52, label %50
50: ; preds = %39
%51 = load i8*, i8** %6
store i8* %51, i8** %5
store i32 1, i32* %13
br label %72
52: ; preds = %39
br label %53
53: ; preds = %52
br label %54
54: ; preds = %53
br label %55
55: ; preds = %54
%56 = load i8*, i8** %9
%57 = call i64 @strcmp(i8* %19, i8* %56)
%58 = icmp eq i64 %57, 0
%59 = zext i1 %58 to i32
store i32 %59, i32* %15
%60 = load i32, i32* %15
%61 = icmp ne i32 %60, 0
%62 = zext i1 %61 to i64
%63 = select i1 %61, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
%64 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %63)
%65 = load i32, i32* %15
%66 = icmp ne i32 %65, 0
br i1 %66, label %69, label %67
67: ; preds = %55
%68 = load i8*, i8** %6
store i8* %68, i8** %5
store i32 1, i32* %13
br label %72
69: ; preds = %55
br label %70
70: ; preds = %69
br label %71
71: ; preds = %70
store i8* null, i8** %5
store i32 1, i32* %13
br label %72
72: ; preds = %71, %67, %50, %34
%73 = load i8*, i8** %10
%74 = load i8*, i8** %5
ret i8* %74
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [2 x i8] c"+\00"
@.str.2 = [2 x i8] c"-\00"
define i8* @test_one_chunk_reverse(i8* readnone %0, i8* %1, i32 %2, i8* %3) {
%5 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%6 = alloca i8, i64 %5
%7 = call i32 @strcpy(i8* %6, i8* %1)
%8 = call i32 @chunk_reverse(i8* %6, i32 %2)
%9 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = call i64 @strlen(i8* %6)
%11 = icmp sgt i64 %10, 0
%12 = select i1 %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
%13 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %12)
br i1 %11, label %14, label %20
14: ; preds = %4
%15 = call i64 @strcmp(i8* %6, i8* %3)
%16 = icmp eq i64 %15, 0
%17 = select i1 %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
%18 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = select i1 %16, i8* null, i8* %0
br label %20
20: ; preds = %14, %4
%21 = phi i8* [ %0, %4 ], [ %19, %14 ]
ret i8* %21
}