#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(int);
scalar_t__ isdigit(int);
char *jas_iccsigtostr(int sig, char *buf) {
  int n;
  int c;
  char *bufptr;
  bufptr = buf;
  for (n = 4; n > 0; --n) {
    c = (sig >> 24) & 0xff;
    if (isalpha(c) || isdigit(c)) {
      *bufptr++ = c;
    }
    sig <<= 8;
  }
  *bufptr = '\0';
  return buf;
}


x86 assembly (clang, -O0):
<jas_iccsigtostr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x4,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    11a7 <jas_iccsigtostr+0x87>
mov    -0x4(%rbp),%eax
sar    $0x18,%eax
and    $0xff,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
call   1040 <isalpha@plt>
cmp    $0x0,%rax
jne    117a <jas_iccsigtostr+0x5a>
mov    -0x18(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     1190 <jas_iccsigtostr+0x70>
mov    -0x18(%rbp),%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
mov    -0x4(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x4(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    113e <jas_iccsigtostr+0x1e>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jas_iccsigtostr>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %edi,%r15d
mov    %edi,%ebp
shr    $0x18,%ebp
mov    %ebp,%edi
call   1040 <isalpha@plt>
test   %rax,%rax
jne    114e <jas_iccsigtostr+0x2e>
mov    %ebp,%edi
call   1030 <isdigit@plt>
mov    %r14,%rbx
test   %rax,%rax
je     1155 <jas_iccsigtostr+0x35>
lea    0x1(%r14),%rbx
mov    %bpl,(%r14)
mov    %r15d,%ebp
shr    $0x10,%ebp
movzbl %bpl,%r12d
mov    %r12d,%edi
call   1040 <isalpha@plt>
test   %rax,%rax
jne    1179 <jas_iccsigtostr+0x59>
mov    %r12d,%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     1180 <jas_iccsigtostr+0x60>
mov    %bpl,(%rbx)
add    $0x1,%rbx
mov    %r15d,%ebp
shr    $0x8,%ebp
movzbl %bpl,%r12d
mov    %r12d,%edi
call   1040 <isalpha@plt>
test   %rax,%rax
jne    11a4 <jas_iccsigtostr+0x84>
mov    %r12d,%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     11ab <jas_iccsigtostr+0x8b>
mov    %bpl,(%rbx)
add    $0x1,%rbx
movzbl %r15b,%ebp
mov    %ebp,%edi
call   1040 <isalpha@plt>
test   %rax,%rax
jne    11c7 <jas_iccsigtostr+0xa7>
mov    %ebp,%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     11ce <jas_iccsigtostr+0xae>
mov    %r15b,(%rbx)
add    $0x1,%rbx
movb   $0x0,(%rbx)
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @jas_iccsigtostr(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%8 = load i8*, i8** %4
store i8* %8, i8** %7
store i32 4, i32* %5
br label %9
9: ; preds = %31, %2
%10 = load i32, i32* %5
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %34
12: ; preds = %9
%13 = load i32, i32* %3
%14 = ashr i32 %13, 24
%15 = and i32 %14, 255
store i32 %15, i32* %6
%16 = load i32, i32* %6
%17 = call i64 @isalpha(i32 %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %12
%20 = load i32, i32* %6
%21 = call i64 @isdigit(i32 %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %28
23: ; preds = %19, %12
%24 = load i32, i32* %6
%25 = trunc i32 %24 to i8
%26 = load i8*, i8** %7
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %7
store i8 %25, i8* %26
br label %28
28: ; preds = %23, %19
%29 = load i32, i32* %3
%30 = shl i32 %29, 8
store i32 %30, i32* %3
br label %31
31: ; preds = %28
%32 = load i32, i32* %5
%33 = add nsw i32 %32, -1
store i32 %33, i32* %5
br label %9
34: ; preds = %9
%35 = load i8*, i8** %7
store i8 0, i8* %35
%36 = load i8*, i8** %4
ret i8* %36
}

LLVM IR (-O2):
define i8* @jas_iccsigtostr(i32 %0, i8* returned writeonly %1) {
%3 = lshr i32 %0, 24
%4 = tail call i64 @isalpha(i32 %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = tail call i64 @isdigit(i32 %3)
%8 = icmp eq i64 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %6, %2
%10 = trunc i32 %3 to i8
%11 = getelementptr inbounds i8, i8* %1, i64 1
store i8 %10, i8* %1
br label %12
12: ; preds = %9, %6
%13 = phi i8* [ %11, %9 ], [ %1, %6 ]
%14 = lshr i32 %0, 16
%15 = and i32 %14, 255
%16 = tail call i64 @isalpha(i32 %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %12
%19 = tail call i64 @isdigit(i32 %15)
%20 = icmp eq i64 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %18, %12
%22 = trunc i32 %14 to i8
%23 = getelementptr inbounds i8, i8* %13, i64 1
store i8 %22, i8* %13
br label %24
24: ; preds = %21, %18
%25 = phi i8* [ %23, %21 ], [ %13, %18 ]
%26 = lshr i32 %0, 8
%27 = and i32 %26, 255
%28 = tail call i64 @isalpha(i32 %27)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %24
%31 = tail call i64 @isdigit(i32 %27)
%32 = icmp eq i64 %31, 0
br i1 %32, label %36, label %33
33: ; preds = %30, %24
%34 = trunc i32 %26 to i8
%35 = getelementptr inbounds i8, i8* %25, i64 1
store i8 %34, i8* %25
br label %36
36: ; preds = %33, %30
%37 = phi i8* [ %35, %33 ], [ %25, %30 ]
%38 = and i32 %0, 255
%39 = tail call i64 @isalpha(i32 %38)
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %36
%42 = tail call i64 @isdigit(i32 %38)
%43 = icmp eq i64 %42, 0
br i1 %43, label %47, label %44
44: ; preds = %41, %36
%45 = trunc i32 %0 to i8
%46 = getelementptr inbounds i8, i8* %37, i64 1
store i8 %45, i8* %37
br label %47
47: ; preds = %44, %41
%48 = phi i8* [ %46, %44 ], [ %37, %41 ]
store i8 0, i8* %48
ret i8* %1
}