#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*/ printf(char *, char *);
int strlen(char *);
int daoxu() {
  char str[] = "hello,world";
  int len = strlen(str);
  char t;
  for (int i = 0; i < len / 2; i++) {
    t = str[i];
    str[i] = str[len - i - 1];
    str[len - i - 1] = t;
  }
  printf("%s\n", str);
  return 0;
}


x86 assembly (clang, -O0):
<daoxu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xed1(%rip),%rax
mov    %rax,-0xc(%rbp)
mov    0xecf(%rip),%eax
mov    %eax,-0x4(%rbp)
lea    -0xc(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    11af <daoxu+0x8f>
movslq -0x18(%rbp),%rax
mov    -0xc(%rbp,%rax,1),%al
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%eax
sub    -0x18(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0xc(%rbp,%rax,1),%cl
movslq -0x18(%rbp),%rax
mov    %cl,-0xc(%rbp,%rax,1)
mov    -0x11(%rbp),%cl
mov    -0x10(%rbp),%eax
sub    -0x18(%rbp),%eax
sub    $0x1,%eax
cltq
mov    %cl,-0xc(%rbp,%rax,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114f <daoxu+0x2f>
lea    -0xc(%rbp),%rsi
lea    0xe52(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<daoxu>:
sub    $0x18,%rsp
movabs $0x6f772c6f6c6c6568,%rax
2c 77 6f
mov    %rax,0x8(%rsp)
movl   $0x646c72,0x10(%rsp)
lea    0x8(%rsp),%rdi
call   1030 <strlen@plt>
cmp    $0x2,%eax
jl     11cc <daoxu+0xac>
mov    %eax,%r8d
shr    %r8d
cmp    $0x1,%r8d
jne    115e <daoxu+0x3e>
xor    %edx,%edx
jmp    11ac <daoxu+0x8c>
mov    %r8d,%r9d
and    $0xfffffffe,%r9d
lea    -0x2(%rax),%edi
xor    %edx,%edx
nopw   0x0(%rax,%rax,1)
movzbl 0x8(%rsp,%rdx,1),%r10d
lea    0x1(%rdi),%esi
movslq %esi,%rsi
movzbl 0x8(%rsp,%rsi,1),%ecx
mov    %cl,0x8(%rsp,%rdx,1)
mov    %r10b,0x8(%rsp,%rsi,1)
movzbl 0x9(%rsp,%rdx,1),%esi
movslq %edi,%rdi
movzbl 0x8(%rsp,%rdi,1),%ecx
mov    %cl,0x9(%rsp,%rdx,1)
mov    %sil,0x8(%rsp,%rdi,1)
add    $0x2,%rdx
add    $0xfffffffe,%edi
cmp    %rdx,%r9
jne    1170 <daoxu+0x50>
test   $0x1,%r8b
je     11cc <daoxu+0xac>
mov    0x8(%rsp,%rdx,1),%dil
mov    %edx,%esi
not    %esi
add    %esi,%eax
cltq
mov    0x8(%rsp,%rax,1),%cl
mov    %cl,0x8(%rsp,%rdx,1)
mov    %dil,0x8(%rsp,%rax,1)
lea    0xe39(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@__const.daoxu.str = [12 x i8] c"hello,world\00"
@.str = [4 x i8] c"%s\0A\00"
define i32 @daoxu() {
%1 = alloca [12 x i8]
%2 = alloca i32
%3 = alloca i8
%4 = alloca i32
%5 = bitcast [12 x i8]* %1 to i8*
%6 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 0
%7 = call i32 @strlen(i8* %6)
store i32 %7, i32* %2
store i32 0, i32* %4
br label %8
8: ; preds = %35, %0
%9 = load i32, i32* %4
%10 = load i32, i32* %2
%11 = sdiv i32 %10, 2
%12 = icmp slt i32 %9, %11
br i1 %12, label %13, label %38
13: ; preds = %8
%14 = load i32, i32* %4
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 %15
%17 = load i8, i8* %16
store i8 %17, i8* %3
%18 = load i32, i32* %2
%19 = load i32, i32* %4
%20 = sub nsw i32 %18, %19
%21 = sub nsw i32 %20, 1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = load i32, i32* %4
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 %26
store i8 %24, i8* %27
%28 = load i8, i8* %3
%29 = load i32, i32* %2
%30 = load i32, i32* %4
%31 = sub nsw i32 %29, %30
%32 = sub nsw i32 %31, 1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 %33
store i8 %28, i8* %34
br label %35
35: ; preds = %13
%36 = load i32, i32* %4
%37 = add nsw i32 %36, 1
store i32 %37, i32* %4
br label %8
38: ; preds = %8
%39 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 0
%40 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %39)
ret i32 0
}

LLVM IR (-O2):
@__const.daoxu.str = [12 x i8] c"hello,world\00"
@.str = [4 x i8] c"%s\0A\00"
define i32 @daoxu() {
%1 = alloca [12 x i8]
%2 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 0
%3 = call i32 @strlen(i8* %2)
%4 = icmp sgt i32 %3, 1
br i1 %4, label %5, label %24
5: ; preds = %0
%6 = lshr i32 %3, 1
%7 = zext i32 %6 to i64
%8 = and i64 %7, 1
%9 = icmp eq i32 %6, 1
br i1 %9, label %12, label %10
10: ; preds = %5
%11 = and i64 %7, 2147483646
br label %26
12: ; preds = %26, %5
%13 = phi i64 [ 0, %5 ], [ %46, %26 ]
%14 = icmp eq i64 %8, 0
br i1 %14, label %24, label %15
15: ; preds = %12
%16 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 %13
%17 = load i8, i8* %16
%18 = trunc i64 %13 to i32
%19 = xor i32 %18, -1
%20 = add i32 %3, %19
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 %21
%23 = load i8, i8* %22
store i8 %23, i8* %16
store i8 %17, i8* %22
br label %24
24: ; preds = %15, %12, %0
%25 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %2)
ret i32 0
26: ; preds = %26, %10
%27 = phi i64 [ 0, %10 ], [ %46, %26 ]
%28 = phi i64 [ 0, %10 ], [ %47, %26 ]
%29 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 %27
%30 = load i8, i8* %29
%31 = trunc i64 %27 to i32
%32 = xor i32 %31, -1
%33 = add i32 %3, %32
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 %34
%36 = load i8, i8* %35
store i8 %36, i8* %29
store i8 %30, i8* %35
%37 = or i64 %27, 1
%38 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 %37
%39 = load i8, i8* %38
%40 = trunc i64 %37 to i32
%41 = xor i32 %40, -1
%42 = add i32 %3, %41
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 %43
%45 = load i8, i8* %44
store i8 %45, i8* %38
store i8 %39, i8* %44
%46 = add nuw nsw i64 %27, 2
%47 = add i64 %28, 2
%48 = icmp eq i64 %47, %11
br i1 %48, label %12, label %26
}