#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 */
scalar_t__ isalpha(char);
scalar_t__ isdigit(char);
scalar_t__ ispunct(char);
scalar_t__ isspace(char);
char *gettype(char *str) {
  char *type = NULL;
  if (isalpha(*str))
    type = "str";
  else if (isdigit(*str))
    type = "digit";
  else if (ispunct(*str))
    type = "punct";
  else if (isspace(*str))
    type = "ws";
  else
    type = "other";
  return type;
}


x86 assembly (clang, -O0):
<gettype>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1060 <isalpha@plt>
cmp    $0x0,%rax
je     117a <gettype+0x3a>
lea    0xe8f(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1206 <gettype+0xc6>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     11a0 <gettype+0x60>
lea    0xe6d(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1201 <gettype+0xc1>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1040 <ispunct@plt>
cmp    $0x0,%rax
je     11c6 <gettype+0x86>
lea    0xe4d(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11fc <gettype+0xbc>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1050 <isspace@plt>
cmp    $0x0,%rax
je     11ec <gettype+0xac>
lea    0xe2d(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11f7 <gettype+0xb7>
lea    0xe20(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11fc <gettype+0xbc>
jmp    1201 <gettype+0xc1>
jmp    1206 <gettype+0xc6>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gettype>:
push   %rbx
mov    %rdi,%rbx
movsbl (%rdi),%edi
call   1060 <isalpha@plt>
test   %rax,%rax
je     115a <gettype+0x1a>
lea    0xea8(%rip),%rax
pop    %rbx
ret
movsbl (%rbx),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     1170 <gettype+0x30>
lea    0xe96(%rip),%rax
pop    %rbx
ret
movsbl (%rbx),%edi
call   1040 <ispunct@plt>
test   %rax,%rax
je     1186 <gettype+0x46>
lea    0xe86(%rip),%rax
pop    %rbx
ret
movsbl (%rbx),%edi
call   1050 <isspace@plt>
test   %rax,%rax
lea    0xe7b(%rip),%rcx
lea    0xe71(%rip),%rax
cmove  %rcx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"str\00"
@.str.1 = [6 x i8] c"digit\00"
@.str.2 = [6 x i8] c"punct\00"
@.str.3 = [3 x i8] c"ws\00"
@.str.4 = [6 x i8] c"other\00"
define i8* @gettype(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
store i8* null, i8** %3
%4 = load i8*, i8** %2
%5 = load i8, i8* %4
%6 = call i64 @isalpha(i8 signext %5)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %3
br label %31
9: ; preds = %1
%10 = load i8*, i8** %2
%11 = load i8, i8* %10
%12 = call i64 @isdigit(i8 signext %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %9
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %30
15: ; preds = %9
%16 = load i8*, i8** %2
%17 = load i8, i8* %16
%18 = call i64 @ispunct(i8 signext %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %15
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8** %3
br label %29
21: ; preds = %15
%22 = load i8*, i8** %2
%23 = load i8, i8* %22
%24 = call i64 @isspace(i8 signext %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %21
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8** %3
br label %28
27: ; preds = %21
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8** %3
br label %28
28: ; preds = %27, %26
br label %29
29: ; preds = %28, %20
br label %30
30: ; preds = %29, %14
br label %31
31: ; preds = %30, %8
%32 = load i8*, i8** %3
ret i8* %32
}

LLVM IR (-O2):
@.str = [4 x i8] c"str\00"
@.str.1 = [6 x i8] c"digit\00"
@.str.2 = [6 x i8] c"punct\00"
@.str.3 = [3 x i8] c"ws\00"
@.str.4 = [6 x i8] c"other\00"
define i8* @gettype(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = tail call i64 @isalpha(i8 signext %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %18
5: ; preds = %1
%6 = load i8, i8* %0
%7 = tail call i64 @isdigit(i8 signext %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %18
9: ; preds = %5
%10 = load i8, i8* %0
%11 = tail call i64 @ispunct(i8 signext %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %9
%14 = load i8, i8* %0
%15 = tail call i64 @isspace(i8 signext %14)
%16 = icmp eq i64 %15, 0
%17 = select i1 %16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0)
br label %18
18: ; preds = %13, %9, %5, %1
%19 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), %5 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), %9 ], [ %17, %13 ]
ret i8* %19
}