#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*/ abort();
char *foo(int, char **);
char *foo2(int, char **);
int /*<<< orphan*/ init(char **);
int main(void) {
  char *list[5];
  char *res;
  init(list);
  res = foo(5, list);
  if (res != (char *)&list[0])
    abort();
  res = foo2(5, list);
  if (res != (char *)&list[5 - 1])
    abort();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
call   1050 <init@plt>
lea    -0x30(%rbp),%rsi
mov    $0x5,%edi
call   1060 <foo@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
lea    -0x30(%rbp),%rcx
cmp    %rcx,%rax
je     1182 <main+0x42>
mov    $0x0,%al
call   1030 <abort@plt>
lea    -0x30(%rbp),%rsi
mov    $0x5,%edi
call   1040 <foo2@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
lea    -0x30(%rbp),%rcx
add    $0x20,%rcx
cmp    %rcx,%rax
je     11b0 <main+0x70>
mov    $0x0,%al
call   1030 <abort@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <init@plt>
mov    $0x5,%edi
mov    %rbx,%rsi
call   1060 <foo@plt>
cmp    %rbx,%rax
jne    1181 <main+0x41>
mov    %rsp,%rsi
mov    $0x5,%edi
call   1040 <foo2@plt>
lea    0x20(%rsp),%rcx
cmp    %rcx,%rax
jne    1181 <main+0x41>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i8*]
%3 = alloca i8*
store i32 0, i32* %1
%4 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 0
%5 = call i32 @init(i8** %4)
%6 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 0
%7 = call i8* @foo(i32 5, i8** %6)
store i8* %7, i8** %3
%8 = load i8*, i8** %3
%9 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 0
%10 = bitcast i8** %9 to i8*
%11 = icmp ne i8* %8, %10
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = call i32 (...) @abort()
unreachable
14: ; preds = %0
%15 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 0
%16 = call i8* @foo2(i32 5, i8** %15)
store i8* %16, i8** %3
%17 = load i8*, i8** %3
%18 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 4
%19 = bitcast i8** %18 to i8*
%20 = icmp ne i8* %17, %19
br i1 %20, label %21, label %23
21: ; preds = %14
%22 = call i32 (...) @abort()
unreachable
23: ; preds = %14
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca [5 x i8*]
%2 = bitcast [5 x i8*]* %1 to i8*
%3 = getelementptr inbounds [5 x i8*], [5 x i8*]* %1, i64 0, i64 0
%4 = call i32 @init(i8** %3)
%5 = call i8* @foo(i32 5, i8** %3)
%6 = icmp eq i8* %5, %2
br i1 %6, label %9, label %7
7: ; preds = %0
%8 = call i32 (...) @abort()
unreachable
9: ; preds = %0
%10 = call i8* @foo2(i32 5, i8** %3)
%11 = getelementptr inbounds [5 x i8*], [5 x i8*]* %1, i64 0, i64 4
%12 = bitcast i8** %11 to i8*
%13 = icmp eq i8* %10, %12
br i1 %13, label %16, label %14
14: ; preds = %9
%15 = call i32 (...) @abort()
unreachable
16: ; preds = %9
ret i32 0
}