#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();
int /*<<< orphan*/ check(int);
g(int *p) {
  static int i;
  switch (i++) {
  case 0:
    check(p[0] == 3);
    check(p[1] == 0);
    check(p[2] == 1);
    break;
  case 1:
    check(p[0] == 2);
    check(p[1] == 5);
    check(p[2] == 9);
    break;
  default:
    abort();
  }
}


x86 assembly (clang, -O0):
<g>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2f02(%rip),%eax
mov    %eax,-0x14(%rbp)
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,0x2ef4(%rip)
test   %eax,%eax
je     115e <g+0x3e>
jmp    114d <g+0x2d>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
je     11a1 <g+0x81>
jmp    11e4 <g+0xc4>
mov    -0x10(%rbp),%rax
cmpl   $0x3,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <check@plt>
mov    -0x10(%rbp),%rax
cmpl   $0x0,0x4(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <check@plt>
mov    -0x10(%rbp),%rax
cmpl   $0x1,0x8(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <check@plt>
jmp    11eb <g+0xcb>
mov    -0x10(%rbp),%rax
cmpl   $0x2,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <check@plt>
mov    -0x10(%rbp),%rax
cmpl   $0x5,0x4(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <check@plt>
mov    -0x10(%rbp),%rax
cmpl   $0x9,0x8(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <check@plt>
jmp    11eb <g+0xcb>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<g>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
mov    0x2f07(%rip),%ebp
lea    0x1(%rbp),%eax
mov    %eax,0x2efe(%rip)
test   %ebp,%ebp
je     1151 <g+0x31>
cmp    $0x1,%ebp
jne    118a <g+0x6a>
mov    $0x9,%r14d
mov    $0x5,%ebp
mov    $0x2,%eax
jmp    115c <g+0x3c>
mov    $0x1,%r14d
mov    $0x3,%eax
xor    %edi,%edi
cmp    %eax,(%rbx)
sete   %dil
call   1040 <check@plt>
xor    %edi,%edi
cmp    %ebp,0x4(%rbx)
sete   %dil
call   1040 <check@plt>
xor    %edi,%edi
cmp    %r14d,0x8(%rbx)
sete   %dil
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <check@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@g.i = internal global i32 0
define i32 @g(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
store i32* %0, i32** %3
%4 = load i32, i32* @g.i
%5 = add nsw i32 %4, 1
store i32 %5, i32* @g.i
switch i32 %4, label %44 [
i32 0, label %6
i32 1, label %25
]
6: ; preds = %1
%7 = load i32*, i32** %3
%8 = getelementptr inbounds i32, i32* %7, i64 0
%9 = load i32, i32* %8
%10 = icmp eq i32 %9, 3
%11 = zext i1 %10 to i32
%12 = call i32 @check(i32 %11)
%13 = load i32*, i32** %3
%14 = getelementptr inbounds i32, i32* %13, i64 1
%15 = load i32, i32* %14
%16 = icmp eq i32 %15, 0
%17 = zext i1 %16 to i32
%18 = call i32 @check(i32 %17)
%19 = load i32*, i32** %3
%20 = getelementptr inbounds i32, i32* %19, i64 2
%21 = load i32, i32* %20
%22 = icmp eq i32 %21, 1
%23 = zext i1 %22 to i32
%24 = call i32 @check(i32 %23)
br label %46
25: ; preds = %1
%26 = load i32*, i32** %3
%27 = getelementptr inbounds i32, i32* %26, i64 0
%28 = load i32, i32* %27
%29 = icmp eq i32 %28, 2
%30 = zext i1 %29 to i32
%31 = call i32 @check(i32 %30)
%32 = load i32*, i32** %3
%33 = getelementptr inbounds i32, i32* %32, i64 1
%34 = load i32, i32* %33
%35 = icmp eq i32 %34, 5
%36 = zext i1 %35 to i32
%37 = call i32 @check(i32 %36)
%38 = load i32*, i32** %3
%39 = getelementptr inbounds i32, i32* %38, i64 2
%40 = load i32, i32* %39
%41 = icmp eq i32 %40, 9
%42 = zext i1 %41 to i32
%43 = call i32 @check(i32 %42)
br label %46
44: ; preds = %1
%45 = call i32 (...) @abort()
unreachable
46: ; preds = %25, %6
%47 = load i32, i32* %2
ret i32 %47
}

LLVM IR (-O2):
@g.i = internal unnamed_addr global i32 0
define i32 @g(i32* nocapture %0) {
%2 = load i32, i32* @g.i
%3 = add nsw i32 %2, 1
store i32 %3, i32* @g.i
switch i32 %2, label %5 [
i32 0, label %7
i32 1, label %4
]
4: ; preds = %1
br label %7
5: ; preds = %1
%6 = tail call i32 (...) @abort()
unreachable
7: ; preds = %1, %4
%8 = phi i32 [ 2, %4 ], [ 3, %1 ]
%9 = phi i32 [ 5, %4 ], [ %2, %1 ]
%10 = phi i32 [ 9, %4 ], [ 1, %1 ]
%11 = load i32, i32* %0
%12 = icmp eq i32 %11, %8
%13 = zext i1 %12 to i32
%14 = tail call i32 @check(i32 %13)
%15 = getelementptr inbounds i32, i32* %0, i64 1
%16 = load i32, i32* %15
%17 = icmp eq i32 %16, %9
%18 = zext i1 %17 to i32
%19 = tail call i32 @check(i32 %18)
%20 = getelementptr inbounds i32, i32* %0, i64 2
%21 = load i32, i32* %20
%22 = icmp eq i32 %21, %10
%23 = zext i1 %22 to i32
%24 = tail call i32 @check(i32 %23)
ret i32 undef
}