#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 */
typedef int /*<<< orphan*/ start;

/* Variables and functions */
int /*<<< orphan*/ abort();
int /*<<< orphan*/ f(void *, int **);
int main() {
  void *p;
  int *q[40];
  long unsigned int start;
  if (sizeof(start) == sizeof(int))
    start = (long unsigned int)0x7fffffff;
  else if (sizeof(start) == sizeof(long))
    start = (long unsigned int)0x7fffffffffffffffL;
  else if (sizeof(start) == sizeof(long long))
    start = (long unsigned int)0x7fffffffffffffffLL;
  else
    return 0;
  start &= -32;
  p = (void *)start;
  q[39] = 0;
  f(p, q);
  if (q[39] != (int *)p + 39)
    abort();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
movl   $0x0,-0x4(%rbp)
movabs $0x7fffffffffffffff,%rax
ff ff 7f
mov    %rax,-0x158(%rbp)
mov    -0x158(%rbp),%rax
and    $0xffffffffffffffe0,%rax
mov    %rax,-0x158(%rbp)
mov    -0x158(%rbp),%rax
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x150(%rbp),%rsi
call   1040 <f@plt>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
add    $0x9c,%rcx
cmp    %rcx,%rax
je     1197 <main+0x77>
mov    $0x0,%al
call   1030 <abort@plt>
xor    %eax,%eax
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x140,%rsp
movq   $0x0,0x138(%rsp)
movabs $0x7fffffffffffffe0,%rbx
ff ff 7f
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1040 <f@plt>
add    $0x9c,%rbx
cmp    %rbx,0x138(%rsp)
jne    1165 <main+0x45>
xor    %eax,%eax
add    $0x140,%rsp
pop    %rbx
ret
xor    %eax,%eax
call   1030 <abort@plt>

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

LLVM IR (-O2):
define i32 @main() {
%1 = alloca [40 x i32*]
%2 = bitcast [40 x i32*]* %1 to i8*
%3 = getelementptr inbounds [40 x i32*], [40 x i32*]* %1, i64 0, i64 39
store i32* null, i32** %3
%4 = getelementptr inbounds [40 x i32*], [40 x i32*]* %1, i64 0, i64 0
%5 = call i32 @f(i8* inttoptr (i64 9223372036854775776 to i8*), i32** %4)
%6 = load i32*, i32** %3
%7 = icmp eq i32* %6, inttoptr (i64 -9223372036854775684 to i32*)
br i1 %7, label %10, label %8
8: ; preds = %0
%9 = call i32 (...) @abort()
unreachable
10: ; preds = %0
ret i32 0
}