#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ isalnum(char);
int /*<<< orphan*/ stderr;
int strlen(char *);
int main(int argc, char *argv[]) {
  char *prefix_name;
  int prefix_leng, i;
  int valid = 1;
  if (argc != 2) {
    fprintf(stderr, "usage) prefixname_test <prefixname>\n");
    exit(-1);
  }
  prefix_name = argv[1];
  prefix_leng = strlen(prefix_name);
  fprintf(stderr, "prefix_name = %s (leng=%d)\n", prefix_name, prefix_leng);
  for (i = 0; i < prefix_leng; i++) {
    if (!isalnum(prefix_name[i])) {
      valid = 0;
      break;
    }
  }
  fprintf(stderr, "prefix_name = %s: %s\n", prefix_name,
          (valid ? "valid" : "invalid"));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x24(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1188 <main+0x48>
mov    0x2e72(%rip),%rax
mov    (%rax),%edi
lea    0xe89(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
lea    0xe6e(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    120a <main+0xca>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <isalnum@plt>
cmp    $0x0,%eax
jne    11f7 <main+0xb7>
movl   $0x0,-0x24(%rbp)
jmp    120a <main+0xca>
jmp    11fc <main+0xbc>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11c5 <main+0x85>
mov    0x2dcf(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
mov    -0x24(%rbp),%esi
lea    0xe36(%rip),%rcx
lea    0xe31(%rip),%rax
cmp    $0x0,%esi
cmovne %rax,%rcx
lea    0xe0b(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    11e4 <main+0xa4>
mov    0x8(%rsi),%r12
mov    %r12,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    0x2e77(%rip),%r15
mov    (%r15),%edi
lea    0xeb2(%rip),%rsi
mov    %r12,%rdx
mov    %eax,%ecx
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0xed3(%rip),%r14
test   %ebp,%ebp
jle    11bc <main+0x7c>
mov    %ebp,%ebp
xor    %ebx,%ebx
lea    0xec2(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
nop
movsbl (%r12,%rbx,1),%edi
call   1040 <isalnum@plt>
test   %eax,%eax
je     11b9 <main+0x79>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    11a0 <main+0x60>
jmp    11bc <main+0x7c>
mov    %r13,%r14
mov    (%r15),%edi
lea    0xe7b(%rip),%rsi
mov    %r12,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1050 <fprintf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2df5(%rip),%rax
mov    (%rax),%edi
lea    0xe0c(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [37 x i8] c"usage) prefixname_test <prefixname>\0A\00"
@.str.1 = [28 x i8] c"prefix_name = %s (leng=%d)\0A\00"
@.str.2 = [22 x i8] c"prefix_name = %s: %s\0A\00"
@.str.3 = [6 x i8] c"valid\00"
@.str.4 = [8 x i8] c"invalid\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %9
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 2
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @exit(i32 -1)
unreachable
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
store i8* %19, i8** %6
%20 = load i8*, i8** %6
%21 = call i32 @strlen(i8* %20)
store i32 %21, i32* %7
%22 = load i32, i32* @stderr
%23 = load i8*, i8** %6
%24 = load i32, i32* %7
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %23, i32 %24)
store i32 0, i32* %8
br label %26
26: ; preds = %40, %16
%27 = load i32, i32* %8
%28 = load i32, i32* %7
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %43
30: ; preds = %26
%31 = load i8*, i8** %6
%32 = load i32, i32* %8
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
%35 = load i8, i8* %34
%36 = call i32 @isalnum(i8 signext %35)
%37 = icmp ne i32 %36, 0
br i1 %37, label %39, label %38
38: ; preds = %30
store i32 0, i32* %9
br label %43
39: ; preds = %30
br label %40
40: ; preds = %39
%41 = load i32, i32* %8
%42 = add nsw i32 %41, 1
store i32 %42, i32* %8
br label %26
43: ; preds = %38, %26
%44 = load i32, i32* @stderr
%45 = load i8*, i8** %6
%46 = load i32, i32* %9
%47 = icmp ne i32 %46, 0
%48 = zext i1 %47 to i64
%49 = select i1 %47, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0)
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %45, i8* %49)
%51 = load i32, i32* %3
ret i32 %51
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [37 x i8] c"usage) prefixname_test <prefixname>\0A\00"
@.str.1 = [28 x i8] c"prefix_name = %s (leng=%d)\0A\00"
@.str.2 = [22 x i8] c"prefix_name = %s: %s\0A\00"
@.str.3 = [6 x i8] c"valid\00"
@.str.4 = [8 x i8] c"invalid\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 -1)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @strlen(i8* %10)
%12 = load i32, i32* @stderr
%13 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %10, i32 %11)
%14 = icmp sgt i32 %11, 0
br i1 %14, label %15, label %26
15: ; preds = %8
%16 = zext i32 %11 to i64
br label %19
17: ; preds = %19
%18 = icmp eq i64 %25, %16
br i1 %18, label %26, label %19
19: ; preds = %15, %17
%20 = phi i64 [ 0, %15 ], [ %25, %17 ]
%21 = getelementptr inbounds i8, i8* %10, i64 %20
%22 = load i8, i8* %21
%23 = tail call i32 @isalnum(i8 signext %22)
%24 = icmp eq i32 %23, 0
%25 = add nuw nsw i64 %20, 1
br i1 %24, label %26, label %17
26: ; preds = %17, %19, %8
%27 = phi i8* [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), %8 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), %19 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), %17 ]
%28 = load i32, i32* @stderr
%29 = tail call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %10, i8* %27)
ret i32 0
}