#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*/ isalpha(char);
int /*<<< orphan*/ isdigit(char);
int /*<<< orphan*/ ispunct(char);
int /*<<< orphan*/ isspace(char);
int /*<<< orphan*/ test(char *, char *);
char *analyse(char *str) {
  char *res = "";
  int a, d, p, s;
  a = d = p = s = 0;
  while (*str != '\0') {
    if (!isalpha(*str))
      a += 1;
    test(res, "a");
    if (!isdigit(*str))
      d += 1;
    test(res, "d");
    if (!ispunct(*str))
      p += 1;
    test(res, "p");
    if (!isspace(*str))
      s += 1;
    test(res, "s");
    str++;
  }
  return res;
}


x86 assembly (clang, -O0):
<analyse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe9e(%rip),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     125c <analyse+0x10c>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1060 <isalpha@plt>
cmp    $0x0,%eax
jne    11b1 <analyse+0x61>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe44(%rip),%rsi
call   1070 <test@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    11df <analyse+0x8f>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe18(%rip),%rsi
call   1070 <test@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1040 <ispunct@plt>
cmp    $0x0,%eax
jne    120d <analyse+0xbd>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xdec(%rip),%rsi
call   1070 <test@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1050 <isspace@plt>
cmp    $0x0,%eax
jne    123b <analyse+0xeb>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xdc0(%rip),%rsi
call   1070 <test@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1183 <analyse+0x33>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<analyse>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    (%rdi),%al
test   %al,%al
je     11e8 <analyse+0x98>
mov    %rdi,%rbx
lea    0xe92(%rip),%r14
lea    0xe8a(%rip),%r15
lea    0xe85(%rip),%r12
lea    0xe80(%rip),%r13
lea    0xe7b(%rip),%rbp
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1060 <isalpha@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1070 <test@plt>
movsbl (%rbx),%edi
call   1030 <isdigit@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1070 <test@plt>
movsbl (%rbx),%edi
call   1040 <ispunct@plt>
mov    %r14,%rdi
mov    %r13,%rsi
call   1070 <test@plt>
movsbl (%rbx),%edi
call   1050 <isspace@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
call   1070 <test@plt>
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1190 <analyse+0x40>
lea    0xe12(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [2 x i8] c"d\00"
@.str.3 = [2 x i8] c"p\00"
@.str.4 = [2 x i8] c"s\00"
define i8* @analyse(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %2
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %3
store i32 0, i32* %7
store i32 0, i32* %6
store i32 0, i32* %5
store i32 0, i32* %4
br label %8
8: ; preds = %51, %1
%9 = load i8*, i8** %2
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %56
13: ; preds = %8
%14 = load i8*, i8** %2
%15 = load i8, i8* %14
%16 = call i32 @isalpha(i8 signext %15)
%17 = icmp ne i32 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %13
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
br label %21
21: ; preds = %18, %13
%22 = load i8*, i8** %3
%23 = call i32 @test(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%24 = load i8*, i8** %2
%25 = load i8, i8* %24
%26 = call i32 @isdigit(i8 signext %25)
%27 = icmp ne i32 %26, 0
br i1 %27, label %31, label %28
28: ; preds = %21
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 1
store i32 %30, i32* %5
br label %31
31: ; preds = %28, %21
%32 = load i8*, i8** %3
%33 = call i32 @test(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%34 = load i8*, i8** %2
%35 = load i8, i8* %34
%36 = call i32 @ispunct(i8 signext %35)
%37 = icmp ne i32 %36, 0
br i1 %37, label %41, label %38
38: ; preds = %31
%39 = load i32, i32* %6
%40 = add nsw i32 %39, 1
store i32 %40, i32* %6
br label %41
41: ; preds = %38, %31
%42 = load i8*, i8** %3
%43 = call i32 @test(i8* %42, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%44 = load i8*, i8** %2
%45 = load i8, i8* %44
%46 = call i32 @isspace(i8 signext %45)
%47 = icmp ne i32 %46, 0
br i1 %47, label %51, label %48
48: ; preds = %41
%49 = load i32, i32* %7
%50 = add nsw i32 %49, 1
store i32 %50, i32* %7
br label %51
51: ; preds = %48, %41
%52 = load i8*, i8** %3
%53 = call i32 @test(i8* %52, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%54 = load i8*, i8** %2
%55 = getelementptr inbounds i8, i8* %54, i32 1
store i8* %55, i8** %2
br label %8
56: ; preds = %8
%57 = load i8*, i8** %3
ret i8* %57
}

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