#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*/ error(char *);
scalar_t__ match(char *);
int /*<<< orphan*/ needbrack(char *);
int /*<<< orphan*/ number(int *);
int needsub(void) {
  int num[1];
  if (match("]"))
    return (0);
  if (!number(num)) {
    error("must be constant");
    num[0] = 1;
  }
  if (num[0] < 0) {
    error("negative size illegal");
    num[0] = (-num[0]);
  }
  needbrack("]");
  return (num[0]);
}


x86 assembly (clang, -O0):
<needsub>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
call   1040 <match@plt>
cmp    $0x0,%rax
je     116a <needsub+0x2a>
movl   $0x0,-0x4(%rbp)
jmp    11bf <needsub+0x7f>
lea    -0x8(%rbp),%rdi
call   1030 <number@plt>
cmp    $0x0,%eax
jne    118f <needsub+0x4f>
lea    0xe7f(%rip),%rdi
call   1060 <error@plt>
movl   $0x1,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    11ad <needsub+0x6d>
lea    0xe73(%rip),%rdi
call   1060 <error@plt>
xor    %eax,%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
lea    0xe4c(%rip),%rdi
call   1050 <needbrack@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<needsub>:
push   %rax
lea    0xeb8(%rip),%rdi
call   1040 <match@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
je     1159 <needsub+0x19>
pop    %rcx
ret
lea    0x4(%rsp),%rdi
call   1030 <number@plt>
test   %eax,%eax
je     1180 <needsub+0x40>
cmpl   $0x0,0x4(%rsp)
jns    1194 <needsub+0x54>
lea    0xe9e(%rip),%rdi
call   1060 <error@plt>
negl   0x4(%rsp)
jmp    1194 <needsub+0x54>
lea    0xe7b(%rip),%rdi
call   1060 <error@plt>
movl   $0x1,0x4(%rsp)
lea    0xe65(%rip),%rdi
call   1050 <needbrack@plt>
mov    0x4(%rsp),%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"]\00"
@.str.1 = [17 x i8] c"must be constant\00"
@.str.2 = [22 x i8] c"negative size illegal\00"
define i32 @needsub() {
%1 = alloca i32
%2 = alloca [1 x i32]
%3 = call i64 @match(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp ne i64 %3, 0
br i1 %4, label %5, label %6
5: ; preds = %0
store i32 0, i32* %1
br label %27
6: ; preds = %0
%7 = getelementptr inbounds [1 x i32], [1 x i32]* %2, i64 0, i64 0
%8 = call i32 @number(i32* %7)
%9 = icmp ne i32 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %6
%11 = call i32 @error(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%12 = getelementptr inbounds [1 x i32], [1 x i32]* %2, i64 0, i64 0
store i32 1, i32* %12
br label %13
13: ; preds = %10, %6
%14 = getelementptr inbounds [1 x i32], [1 x i32]* %2, i64 0, i64 0
%15 = load i32, i32* %14
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %23
17: ; preds = %13
%18 = call i32 @error(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%19 = getelementptr inbounds [1 x i32], [1 x i32]* %2, i64 0, i64 0
%20 = load i32, i32* %19
%21 = sub nsw i32 0, %20
%22 = getelementptr inbounds [1 x i32], [1 x i32]* %2, i64 0, i64 0
store i32 %21, i32* %22
br label %23
23: ; preds = %17, %13
%24 = call i32 @needbrack(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%25 = getelementptr inbounds [1 x i32], [1 x i32]* %2, i64 0, i64 0
%26 = load i32, i32* %25
store i32 %26, i32* %1
br label %27
27: ; preds = %23, %5
%28 = load i32, i32* %1
ret i32 %28
}

LLVM IR (-O2):
@.str = [2 x i8] c"]\00"
@.str.1 = [17 x i8] c"must be constant\00"
@.str.2 = [22 x i8] c"negative size illegal\00"
define i32 @needsub() {
%1 = alloca [1 x i32]
%2 = bitcast [1 x i32]* %1 to i8*
%3 = tail call i64 @match(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %21
5: ; preds = %0
%6 = getelementptr inbounds [1 x i32], [1 x i32]* %1, i64 0, i64 0
%7 = call i32 @number(i32* %6)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = call i32 @error(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %6
br label %18
11: ; preds = %5
%12 = load i32, i32* %6
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %11
%15 = call i32 @error(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%16 = load i32, i32* %6
%17 = sub nsw i32 0, %16
store i32 %17, i32* %6
br label %18
18: ; preds = %9, %14, %11
%19 = call i32 @needbrack(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%20 = load i32, i32* %6
br label %21
21: ; preds = %0, %18
%22 = phi i32 [ %20, %18 ], [ 0, %0 ]
ret i32 %22
}