#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 *strdup(char *);
int /*<<< orphan*/ yyerror(char *);
char *newnum(char *yyInText) {
  int zeros = 0;
  char *p;
  while (*(yyInText + zeros) == '0')
    zeros++;
  if (zeros && !(*(yyInText + zeros)) && *(yyInText + zeros - 1) == '0')
    zeros--;
  if (!(p = strdup(yyInText))) {
    yyerror("newnum: out of space");
    abort();
  }
  return p;
}


x86 assembly (clang, -O0):
<newnum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x30,%eax
jne    1166 <newnum+0x36>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1143 <newnum+0x13>
cmpl   $0x0,-0xc(%rbp)
je     11a1 <newnum+0x71>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
jne    11a1 <newnum+0x71>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl -0x1(%rax,%rcx,1),%eax
cmp    $0x30,%eax
jne    11a1 <newnum+0x71>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strdup@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11cb <newnum+0x9b>
lea    0xe41(%rip),%rdi
call   1040 <yyerror@plt>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<newnum>:
push   %rax
call   1050 <strdup@plt>
test   %rax,%rax
je     113d <newnum+0xd>
pop    %rcx
ret
lea    0xebc(%rip),%rdi
call   1040 <yyerror@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"newnum: out of space\00"
define i8* @newnum(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
store i8* %0, i8** %2
store i32 0, i32* %3
br label %5
5: ; preds = %13, %1
%6 = load i8*, i8** %2
%7 = load i32, i32* %3
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %6, i64 %8
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 48
br i1 %12, label %13, label %16
13: ; preds = %5
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
store i32 %15, i32* %3
br label %5
16: ; preds = %5
%17 = load i32, i32* %3
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %38
19: ; preds = %16
%20 = load i8*, i8** %2
%21 = load i32, i32* %3
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = load i8, i8* %23
%25 = icmp ne i8 %24, 0
br i1 %25, label %38, label %26
26: ; preds = %19
%27 = load i8*, i8** %2
%28 = load i32, i32* %3
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = getelementptr inbounds i8, i8* %30, i64 -1
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 48
br i1 %34, label %35, label %38
35: ; preds = %26
%36 = load i32, i32* %3
%37 = add nsw i32 %36, -1
store i32 %37, i32* %3
br label %38
38: ; preds = %35, %26, %19, %16
%39 = load i8*, i8** %2
%40 = call i8* @strdup(i8* %39)
store i8* %40, i8** %4
%41 = icmp ne i8* %40, null
br i1 %41, label %45, label %42
42: ; preds = %38
%43 = call i32 @yyerror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%44 = call i32 (...) @abort()
unreachable
45: ; preds = %38
%46 = load i8*, i8** %4
ret i8* %46
}

LLVM IR (-O2):
@.str = [21 x i8] c"newnum: out of space\00"
define noalias i8* @newnum(i8* nocapture %0) {
%2 = tail call i8* @strdup(i8* %0)
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = tail call i32 @yyerror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 (...) @abort()
unreachable
7: ; preds = %1
ret i8* %2
}