#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 */
size_t string_list_length(char const **);
size_t string_list_reverse(char **list) {
  size_t length = string_list_length((const char **)list);
  if (length) {
    size_t i = 0, j = length - 1;
    for (; i < j; ++i, --j) {
      char *swap = list[i];
      list[i] = list[j];
      list[j] = swap;
    }
  }
  return length;
}


x86 assembly (clang, -O0):
<string_list_reverse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <string_list_length@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11b0 <string_list_reverse+0xa0>
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
sub    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    11ab <string_list_reverse+0x9b>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x28(%rbp),%rdx
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
jmp    1148 <string_list_reverse+0x38>
jmp    11b0 <string_list_reverse+0xa0>
mov    -0x10(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<string_list_reverse>:
push   %rbx
mov    %rdi,%rbx
call   1030 <string_list_length@plt>
cmp    $0x2,%rax
jb     1152 <string_list_reverse+0x42>
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    $0x1,%edx
nopl   0x0(%rax,%rax,1)
mov    -0x8(%rbx,%rdx,8),%rsi
mov    (%rbx,%rcx,8),%rdi
mov    %rdi,-0x8(%rbx,%rdx,8)
mov    %rsi,(%rbx,%rcx,8)
add    $0xffffffffffffffff,%rcx
lea    0x1(%rdx),%rsi
cmp    %rcx,%rdx
mov    %rsi,%rdx
jb     1130 <string_list_reverse+0x20>
pop    %rbx
ret

LLVM IR (-O0):
define i64 @string_list_reverse(i8** %0) {
%2 = alloca i8**
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i8*
store i8** %0, i8*** %2
%7 = load i8**, i8*** %2
%8 = call i64 @string_list_length(i8** %7)
store i64 %8, i64* %3
%9 = load i64, i64* %3
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %40
11: ; preds = %1
store i64 0, i64* %4
%12 = load i64, i64* %3
%13 = sub i64 %12, 1
store i64 %13, i64* %5
br label %14
14: ; preds = %34, %11
%15 = load i64, i64* %4
%16 = load i64, i64* %5
%17 = icmp ult i64 %15, %16
br i1 %17, label %18, label %39
18: ; preds = %14
%19 = load i8**, i8*** %2
%20 = load i64, i64* %4
%21 = getelementptr inbounds i8*, i8** %19, i64 %20
%22 = load i8*, i8** %21
store i8* %22, i8** %6
%23 = load i8**, i8*** %2
%24 = load i64, i64* %5
%25 = getelementptr inbounds i8*, i8** %23, i64 %24
%26 = load i8*, i8** %25
%27 = load i8**, i8*** %2
%28 = load i64, i64* %4
%29 = getelementptr inbounds i8*, i8** %27, i64 %28
store i8* %26, i8** %29
%30 = load i8*, i8** %6
%31 = load i8**, i8*** %2
%32 = load i64, i64* %5
%33 = getelementptr inbounds i8*, i8** %31, i64 %32
store i8* %30, i8** %33
br label %34
34: ; preds = %18
%35 = load i64, i64* %4
%36 = add i64 %35, 1
store i64 %36, i64* %4
%37 = load i64, i64* %5
%38 = add i64 %37, -1
store i64 %38, i64* %5
br label %14
39: ; preds = %14
br label %40
40: ; preds = %39, %1
%41 = load i64, i64* %3
ret i64 %41
}

LLVM IR (-O2):
define i64 @string_list_reverse(i8** %0) {
%2 = tail call i64 @string_list_length(i8** %0)
%3 = icmp ugt i64 %2, 1
br i1 %3, label %4, label %16
4: ; preds = %1
%5 = add i64 %2, -1
br label %6
6: ; preds = %4, %6
%7 = phi i64 [ %14, %6 ], [ %5, %4 ]
%8 = phi i64 [ %13, %6 ], [ 0, %4 ]
%9 = getelementptr inbounds i8*, i8** %0, i64 %8
%10 = load i8*, i8** %9
%11 = getelementptr inbounds i8*, i8** %0, i64 %7
%12 = load i8*, i8** %11
store i8* %12, i8** %9
store i8* %10, i8** %11
%13 = add nuw i64 %8, 1
%14 = add i64 %7, -1
%15 = icmp ult i64 %13, %14
br i1 %15, label %6, label %16
16: ; preds = %6, %1
ret i64 %2
}