#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*/ IntToStr(int);
scalar_t__ NumDigits(int);
int /*<<< orphan*/ exit(int);
scalar_t__ malloc(scalar_t__);
int /*<<< orphan*/ printf(char *);
char *strcat(char *, int /*<<< orphan*/);
char *strcpy(char *, char *);
char *NewTypeVar(void) {
  extern int typenum;
  char *tmp;
  if (typenum < 0) {
    printf("internal error: typenum < 0 in NewType\n");
    exit(1);
  }
  typenum++;
  tmp = (char *)malloc(NumDigits(typenum) + 2);
  tmp = strcpy(tmp, "t");
  tmp = strcat(tmp, IntToStr(typenum));
  return (tmp);
}


x86 assembly (clang, -O0):
<NewTypeVar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e69(%rip),%rax
cmpl   $0x0,(%rax)
jge    119e <NewTypeVar+0x2e>
lea    0xe71(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    0x2e43(%rip),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    0x2e37(%rip),%rax
mov    %ecx,(%rax)
mov    0x2e2e(%rip),%rax
mov    (%rax),%edi
call   1070 <NumDigits@plt>
mov    %rax,%rdi
add    $0x2,%rdi
call   1060 <malloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe4c(%rip),%rsi
call   1030 <strcpy@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    0x2df4(%rip),%rax
mov    (%rax),%edi
call   1050 <IntToStr@plt>
mov    -0x10(%rbp),%rdi
mov    %eax,%esi
call   1080 <strcat@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<NewTypeVar>:
push   %r14
push   %rbx
push   %rax
mov    0x2e7d(%rip),%r14
mov    (%r14),%edi
test   %edi,%edi
js     11a7 <NewTypeVar+0x47>
add    $0x1,%edi
mov    %edi,(%r14)
call   1060 <NumDigits@plt>
lea    0x2(%rax),%rdi
call   1050 <malloc@plt>
mov    %rax,%rbx
movw   $0x74,(%rax)
mov    (%r14),%edi
call   1040 <IntToStr@plt>
mov    %rbx,%rdi
mov    %eax,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1070 <strcat@plt>
lea    0xe52(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@typenum = external global i32
@.str = [40 x i8] c"internal error: typenum < 0 in NewType\0A\00"
@.str.1 = [2 x i8] c"t\00"
define i8* @NewTypeVar() {
%1 = alloca i8*
%2 = load i32, i32* @typenum
%3 = icmp slt i32 %2, 0
br i1 %3, label %4, label %7
4: ; preds = %0
%5 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @exit(i32 1)
unreachable
7: ; preds = %0
%8 = load i32, i32* @typenum
%9 = add nsw i32 %8, 1
store i32 %9, i32* @typenum
%10 = load i32, i32* @typenum
%11 = call i64 @NumDigits(i32 %10)
%12 = add nsw i64 %11, 2
%13 = call i64 @malloc(i64 %12)
%14 = inttoptr i64 %13 to i8*
store i8* %14, i8** %1
%15 = load i8*, i8** %1
%16 = call i8* @strcpy(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %16, i8** %1
%17 = load i8*, i8** %1
%18 = load i32, i32* @typenum
%19 = call i32 @IntToStr(i32 %18)
%20 = call i8* @strcat(i8* %17, i32 %19)
store i8* %20, i8** %1
%21 = load i8*, i8** %1
ret i8* %21
}

LLVM IR (-O2):
@typenum = external global i32
@str = [39 x i8] c"internal error: typenum < 0 in NewType\00"
define i8* @NewTypeVar() {
%1 = load i32, i32* @typenum
%2 = icmp slt i32 %1, 0
br i1 %2, label %3, label %6
3: ; preds = %0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 @exit(i32 1)
unreachable
6: ; preds = %0
%7 = add nuw nsw i32 %1, 1
store i32 %7, i32* @typenum
%8 = tail call i64 @NumDigits(i32 %7)
%9 = add nsw i64 %8, 2
%10 = tail call i64 @malloc(i64 %9)
%11 = inttoptr i64 %10 to i8*
%12 = inttoptr i64 %10 to i16*
store i16 116, i16* %12
%13 = load i32, i32* @typenum
%14 = tail call i32 @IntToStr(i32 %13)
%15 = tail call i8* @strcat(i8* %11, i32 %14)
ret i8* %15
}