#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*/ putchar(char);
int reverse_string(char string[]) {
  int i;
  int size = 0;
  while (string[size] != '\0') {
    size++;
  }
  for (i = size - 1; i >= 0; i--) {
    putchar(string[i]);
  }
  return size;
}


x86 assembly (clang, -O0):
<reverse_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1146 <reverse_string+0x36>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1123 <reverse_string+0x13>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     1178 <reverse_string+0x68>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <putchar@plt>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    114f <reverse_string+0x3f>
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reverse_string>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r15
xor    %ebx,%ebx
nopl   (%rax)
cmpb   $0x0,(%r15,%rbx,1)
lea    0x1(%rbx),%rbx
jne    1120 <reverse_string+0x10>
lea    -0x1(%rbx),%r14
cmp    $0x1,%ebx
je     1159 <reverse_string+0x49>
lea    -0x1(%rbx),%r12d
add    $0xffffffffffffffff,%r12
nopl   0x0(%rax)
mov    %r12d,%eax
movsbl (%r15,%rax,1),%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
add    $0xffffffffffffffff,%r12
cmp    $0x1,%ebx
jg     1140 <reverse_string+0x30>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @reverse_string(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %4
br label %5
5: ; preds = %13, %1
%6 = load i8*, i8** %2
%7 = load i32, i32* %4
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %6, i64 %8
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %5
%14 = load i32, i32* %4
%15 = add nsw i32 %14, 1
store i32 %15, i32* %4
br label %5
16: ; preds = %5
%17 = load i32, i32* %4
%18 = sub nsw i32 %17, 1
store i32 %18, i32* %3
br label %19
19: ; preds = %29, %16
%20 = load i32, i32* %3
%21 = icmp sge i32 %20, 0
br i1 %21, label %22, label %32
22: ; preds = %19
%23 = load i8*, i8** %2
%24 = load i32, i32* %3
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = call i32 @putchar(i8 signext %27)
br label %29
29: ; preds = %22
%30 = load i32, i32* %3
%31 = add nsw i32 %30, -1
store i32 %31, i32* %3
br label %19
32: ; preds = %19
%33 = load i32, i32* %4
ret i32 %33
}

LLVM IR (-O2):
define i32 @reverse_string(i8* nocapture %0) {
br label %2
2: ; preds = %2, %1
%3 = phi i64 [ %7, %2 ], [ 0, %1 ]
%4 = getelementptr inbounds i8, i8* %0, i64 %3
%5 = load i8, i8* %4
%6 = icmp eq i8 %5, 0
%7 = add nuw i64 %3, 1
br i1 %6, label %8, label %2
8: ; preds = %2
%9 = trunc i64 %3 to i32
%10 = icmp eq i32 %9, 0
br i1 %10, label %22, label %11
11: ; preds = %8
%12 = and i64 %3, 4294967295
br label %13
13: ; preds = %11, %13
%14 = phi i64 [ %12, %11 ], [ %15, %13 ]
%15 = add nsw i64 %14, -1
%16 = and i64 %15, 4294967295
%17 = getelementptr inbounds i8, i8* %0, i64 %16
%18 = load i8, i8* %17
%19 = tail call i32 @putchar(i8 signext %18)
%20 = trunc i64 %14 to i32
%21 = icmp sgt i32 %20, 1
br i1 %21, label %13, label %22
22: ; preds = %13, %8
ret i32 %9
}