#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, ...);
void reverse_my(char *source, char *rev) {
  int i = 0;
  while (*source != '\0') {
    i++;
    printf("int first while * source = %c;\n", *source);
    *source++;
  };
  *source--;
  printf(
      "before second while cycle * source = \"%c\" in char and %d in digit;\n",
      *source, *source);
  while (i > 0) {
    *rev++ = *source--;
    i--;
    *rev--;
    printf("in second while * rev = %c;\n", *rev);
    *rev++;
  };
  *rev = '\0';
}


x86 assembly (clang, -O0):
<reverse_my>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1166 <reverse_my+0x56>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
lea    0xeb5(%rip),%rdi
movsbl (%rax),%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1127 <reverse_my+0x17>
mov    -0x8(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    -0x8(%rbp),%rcx
movsbl (%rcx),%edx
lea    0xe9a(%rip),%rdi
movsbl %al,%esi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x14(%rbp)
jle    11f7 <reverse_my+0xe7>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
lea    0xe88(%rip),%rdi
movsbl (%rax),%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1190 <reverse_my+0x80>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reverse_my>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %rdi,%r14
mov    (%rdi),%al
test   %al,%al
je     11a5 <reverse_my+0x95>
mov    $0xffffffffffffffff,%rbx
lea    0xeca(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
movsbl %al,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movzbl 0x2(%r14,%rbx,1),%eax
add    $0x1,%rbx
test   %al,%al
jne    1140 <reverse_my+0x30>
movsbl (%r14,%rbx,1),%edx
lea    0xeb9(%rip),%rdi
mov    %edx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeed(%rip),%r15
nopw   0x0(%rax,%rax,1)
movsbl (%r14,%rbx,1),%esi
mov    %sil,(%r12)
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%r12
add    $0xffffffffffffffff,%rbx
lea    0x2(%rbx),%eax
cmp    $0x1,%eax
jg     1180 <reverse_my+0x70>
jmp    11ba <reverse_my+0xaa>
movsbl -0x1(%r14),%edx
lea    0xe6f(%rip),%rdi
mov    %edx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
movb   $0x0,(%r12)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [32 x i8] c"int first while * source = %c;\0A\00"
@.str.1 = [68 x i8] c"before second while cycle * source = \22%c\22 in char and %d in digit;\0A\00"
@.str.2 = [29 x i8] c"in second while * rev = %c;\0A\00"
define void @reverse_my(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %5
br label %6
6: ; preds = %11, %2
%7 = load i8*, i8** %3
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %20
11: ; preds = %6
%12 = load i32, i32* %5
%13 = add nsw i32 %12, 1
store i32 %13, i32* %5
%14 = load i8*, i8** %3
%15 = load i8, i8* %14
%16 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8 signext %15)
%17 = load i8*, i8** %3
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %3
%19 = load i8, i8* %17
br label %6
20: ; preds = %6
%21 = load i8*, i8** %3
%22 = getelementptr inbounds i8, i8* %21, i32 -1
store i8* %22, i8** %3
%23 = load i8, i8* %21
%24 = load i8*, i8** %3
%25 = load i8, i8* %24
%26 = load i8*, i8** %3
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.1, i64 0, i64 0), i8 signext %25, i32 %28)
br label %30
30: ; preds = %33, %20
%31 = load i32, i32* %5
%32 = icmp sgt i32 %31, 0
br i1 %32, label %33, label %50
33: ; preds = %30
%34 = load i8*, i8** %3
%35 = getelementptr inbounds i8, i8* %34, i32 -1
store i8* %35, i8** %3
%36 = load i8, i8* %34
%37 = load i8*, i8** %4
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %4
store i8 %36, i8* %37
%39 = load i32, i32* %5
%40 = add nsw i32 %39, -1
store i32 %40, i32* %5
%41 = load i8*, i8** %4
%42 = getelementptr inbounds i8, i8* %41, i32 -1
store i8* %42, i8** %4
%43 = load i8, i8* %41
%44 = load i8*, i8** %4
%45 = load i8, i8* %44
%46 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8 signext %45)
%47 = load i8*, i8** %4
%48 = getelementptr inbounds i8, i8* %47, i32 1
store i8* %48, i8** %4
%49 = load i8, i8* %47
br label %30
50: ; preds = %30
%51 = load i8*, i8** %4
store i8 0, i8* %51
ret void
}

LLVM IR (-O2):
@.str = [32 x i8] c"int first while * source = %c;\0A\00"
@.str.1 = [68 x i8] c"before second while cycle * source = \22%c\22 in char and %d in digit;\0A\00"
@.str.2 = [29 x i8] c"in second while * rev = %c;\0A\00"
define void @reverse_my(i8* nocapture %0, i8* nocapture writeonly %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %14, label %5
5: ; preds = %2, %5
%6 = phi i8 [ %12, %5 ], [ %3, %2 ]
%7 = phi i32 [ %9, %5 ], [ 0, %2 ]
%8 = phi i8* [ %11, %5 ], [ %0, %2 ]
%9 = add nuw nsw i32 %7, 1
%10 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8 signext %6)
%11 = getelementptr inbounds i8, i8* %8, i64 1
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
br i1 %13, label %19, label %5
14: ; preds = %2
%15 = getelementptr inbounds i8, i8* %0, i64 -1
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.1, i64 0, i64 0), i8 signext %16, i32 %17)
br label %33
19: ; preds = %5
%20 = load i8, i8* %8
%21 = sext i8 %20 to i32
%22 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.1, i64 0, i64 0), i8 signext %20, i32 %21)
br label %23
23: ; preds = %19, %23
%24 = phi i32 [ %29, %23 ], [ %9, %19 ]
%25 = phi i8* [ %31, %23 ], [ %1, %19 ]
%26 = phi i8* [ %27, %23 ], [ %8, %19 ]
%27 = getelementptr inbounds i8, i8* %26, i64 -1
%28 = load i8, i8* %26
store i8 %28, i8* %25
%29 = add nsw i32 %24, -1
%30 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8 signext %28)
%31 = getelementptr inbounds i8, i8* %25, i64 1
%32 = icmp sgt i32 %24, 1
br i1 %32, label %23, label %33
33: ; preds = %23, %14
%34 = phi i8* [ %1, %14 ], [ %31, %23 ]
store i8 0, i8* %34
ret void
}