#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*/ assert(int);
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/);
int /*<<< orphan*/ reverse(char *, int);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void test_reverse() {
  char str[10] = {0};
  int testnum = 1;
  strcpy(str, "hello");
  reverse(str, 5);
  assert(strcmp("olleh", str) == 0);
  printf("test %d pass\n", testnum++);
  strcpy(str, "tablet");
  reverse(str, 6);
  assert(strcmp("telbat", str) == 0);
  printf("test %d pass\n", testnum++);
  strcpy(str, "hi");
  reverse(str, 2);
  assert(strcmp("ih", str) == 0);
  printf("test %d pass\n", testnum++);
  strcpy(str, "hey");
  reverse(str, 3);
  assert(strcmp("yeh", str) == 0);
  printf("test %d pass\n", testnum++);
  strcpy(str, "i");
  reverse(str, 1);
  assert(strcmp("i", str) == 0);
  printf("test %d pass\n", testnum++);
  strcpy(str, "");
  reverse(str, 0);
  assert(strcmp("", str) == 0);
  printf("test %d pass\n", testnum++);
}


x86 assembly (clang, -O0):
<test_reverse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0xa(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1060 <memset@plt>
movl   $0x1,-0x10(%rbp)
lea    -0xa(%rbp),%rdi
lea    0xe76(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0xa(%rbp),%rdi
mov    $0x5,%esi
call   1030 <reverse@plt>
lea    -0xa(%rbp),%rsi
lea    0xe5e(%rip),%rdi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    -0x10(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
lea    0xe3c(%rip),%rdi
call   1050 <printf@plt>
lea    -0xa(%rbp),%rdi
lea    0xe3a(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0xa(%rbp),%rdi
mov    $0x6,%esi
call   1030 <reverse@plt>
lea    -0xa(%rbp),%rsi
lea    0xe23(%rip),%rdi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    -0x10(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
lea    0xde6(%rip),%rdi
call   1050 <printf@plt>
lea    -0xa(%rbp),%rdi
lea    0xdf2(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0xa(%rbp),%rdi
mov    $0x2,%esi
call   1030 <reverse@plt>
lea    -0xa(%rbp),%rsi
lea    0xdd7(%rip),%rdi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    -0x10(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
lea    0xd90(%rip),%rdi
call   1050 <printf@plt>
lea    -0xa(%rbp),%rdi
lea    0xda2(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0xa(%rbp),%rdi
mov    $0x3,%esi
call   1030 <reverse@plt>
lea    -0xa(%rbp),%rsi
lea    0xd88(%rip),%rdi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    -0x10(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
lea    0xd3a(%rip),%rdi
call   1050 <printf@plt>
lea    -0xa(%rbp),%rdi
lea    0xd47(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0xa(%rbp),%rdi
mov    $0x1,%esi
call   1030 <reverse@plt>
lea    -0xa(%rbp),%rsi
lea    0xd29(%rip),%rdi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    -0x10(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
lea    0xce4(%rip),%rdi
call   1050 <printf@plt>
lea    -0xa(%rbp),%rdi
lea    0xce1(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0xa(%rbp),%rdi
xor    %esi,%esi
call   1030 <reverse@plt>
lea    -0xa(%rbp),%rsi
lea    0xcc6(%rip),%rdi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    -0x10(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
lea    0xc91(%rip),%rdi
call   1050 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_reverse>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movw   $0x0,0x8(%rsp)
movq   $0x0,(%rsp)
lea    0xe91(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
call   1030 <reverse@plt>
lea    0xe78(%rip),%rdi
mov    %rbx,%rsi
call   1060 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1070 <assert@plt>
lea    0xe61(%rip),%r14
mov    %r14,%rdi
mov    $0x1,%esi
call   1050 <printf@plt>
lea    0xe5b(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
call   1030 <reverse@plt>
lea    0xe46(%rip),%rdi
mov    %rbx,%rsi
call   1060 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1070 <assert@plt>
mov    %r14,%rdi
mov    $0x2,%esi
call   1050 <printf@plt>
lea    0xe23(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
call   1030 <reverse@plt>
lea    0xe0a(%rip),%rdi
mov    %rbx,%rsi
call   1060 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1070 <assert@plt>
mov    %r14,%rdi
mov    $0x3,%esi
call   1050 <printf@plt>
lea    0xde3(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
call   1030 <reverse@plt>
lea    0xdcb(%rip),%rdi
mov    %rbx,%rsi
call   1060 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1070 <assert@plt>
mov    %r14,%rdi
mov    $0x4,%esi
call   1050 <printf@plt>
lea    0xd98(%rip),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1030 <reverse@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1070 <assert@plt>
mov    %r14,%rdi
mov    $0x5,%esi
call   1050 <printf@plt>
lea    0xd43(%rip),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <reverse@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1070 <assert@plt>
mov    %r14,%rdi
mov    $0x6,%esi
call   1050 <printf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [6 x i8] c"hello\00"
@.str.1 = [6 x i8] c"olleh\00"
@.str.2 = [14 x i8] c"test %d pass\0A\00"
@.str.3 = [7 x i8] c"tablet\00"
@.str.4 = [7 x i8] c"telbat\00"
@.str.5 = [3 x i8] c"hi\00"
@.str.6 = [3 x i8] c"ih\00"
@.str.7 = [4 x i8] c"hey\00"
@.str.8 = [4 x i8] c"yeh\00"
@.str.9 = [2 x i8] c"i\00"
@.str.10 = [1 x i8] zeroinitializer
define void @test_reverse() {
%1 = alloca [10 x i8]
%2 = alloca i32
%3 = bitcast [10 x i8]* %1 to i8*
store i32 1, i32* %2
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%5 = call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%7 = call i32 @reverse(i8* %6, i32 5)
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%9 = call i64 @strcmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = icmp eq i64 %9, 0
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = load i32, i32* %2
%14 = add nsw i32 %13, 1
store i32 %14, i32* %2
%15 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %13)
%16 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%17 = call i32 @strcpy(i8* %16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%18 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%19 = call i32 @reverse(i8* %18, i32 6)
%20 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%21 = call i64 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %20)
%22 = icmp eq i64 %21, 0
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
%25 = load i32, i32* %2
%26 = add nsw i32 %25, 1
store i32 %26, i32* %2
%27 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %25)
%28 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%29 = call i32 @strcpy(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%30 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%31 = call i32 @reverse(i8* %30, i32 2)
%32 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%33 = call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %32)
%34 = icmp eq i64 %33, 0
%35 = zext i1 %34 to i32
%36 = call i32 @assert(i32 %35)
%37 = load i32, i32* %2
%38 = add nsw i32 %37, 1
store i32 %38, i32* %2
%39 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %37)
%40 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%41 = call i32 @strcpy(i8* %40, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%42 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%43 = call i32 @reverse(i8* %42, i32 3)
%44 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%45 = call i64 @strcmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* %44)
%46 = icmp eq i64 %45, 0
%47 = zext i1 %46 to i32
%48 = call i32 @assert(i32 %47)
%49 = load i32, i32* %2
%50 = add nsw i32 %49, 1
store i32 %50, i32* %2
%51 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %49)
%52 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%53 = call i32 @strcpy(i8* %52, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%54 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%55 = call i32 @reverse(i8* %54, i32 1)
%56 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%57 = call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i8* %56)
%58 = icmp eq i64 %57, 0
%59 = zext i1 %58 to i32
%60 = call i32 @assert(i32 %59)
%61 = load i32, i32* %2
%62 = add nsw i32 %61, 1
store i32 %62, i32* %2
%63 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %61)
%64 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%65 = call i32 @strcpy(i8* %64, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.10, i64 0, i64 0))
%66 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%67 = call i32 @reverse(i8* %66, i32 0)
%68 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%69 = call i64 @strcmp(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.10, i64 0, i64 0), i8* %68)
%70 = icmp eq i64 %69, 0
%71 = zext i1 %70 to i32
%72 = call i32 @assert(i32 %71)
%73 = load i32, i32* %2
%74 = add nsw i32 %73, 1
store i32 %74, i32* %2
%75 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %73)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"hello\00"
@.str.1 = [6 x i8] c"olleh\00"
@.str.2 = [14 x i8] c"test %d pass\0A\00"
@.str.3 = [7 x i8] c"tablet\00"
@.str.4 = [7 x i8] c"telbat\00"
@.str.5 = [3 x i8] c"hi\00"
@.str.6 = [3 x i8] c"ih\00"
@.str.7 = [4 x i8] c"hey\00"
@.str.8 = [4 x i8] c"yeh\00"
@.str.9 = [2 x i8] c"i\00"
@.str.10 = [1 x i8] zeroinitializer
define void @test_reverse() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%3 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @reverse(i8* %2, i32 5)
%5 = call i64 @strcmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%6 = icmp eq i64 %5, 0
%7 = zext i1 %6 to i32
%8 = call i32 @assert(i32 %7)
%9 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 1)
%10 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @reverse(i8* %2, i32 6)
%12 = call i64 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %2)
%13 = icmp eq i64 %12, 0
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 2)
%17 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%18 = call i32 @reverse(i8* %2, i32 2)
%19 = call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %2)
%20 = icmp eq i64 %19, 0
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
%23 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 3)
%24 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%25 = call i32 @reverse(i8* %2, i32 3)
%26 = call i64 @strcmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* %2)
%27 = icmp eq i64 %26, 0
%28 = zext i1 %27 to i32
%29 = call i32 @assert(i32 %28)
%30 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 4)
%31 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%32 = call i32 @reverse(i8* %2, i32 1)
%33 = call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i8* %2)
%34 = icmp eq i64 %33, 0
%35 = zext i1 %34 to i32
%36 = call i32 @assert(i32 %35)
%37 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 5)
%38 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.10, i64 0, i64 0))
%39 = call i32 @reverse(i8* %2, i32 0)
%40 = call i64 @strcmp(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.10, i64 0, i64 0), i8* %2)
%41 = icmp eq i64 %40, 0
%42 = zext i1 %41 to i32
%43 = call i32 @assert(i32 %42)
%44 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 6)
ret void
}