#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 */
struct obstack {
  int dummy;
};

/* Variables and functions */
scalar_t__ isalnum(char const);
scalar_t__ isdigit(char const);
int /*<<< orphan*/ obstack_1grow(struct obstack *, char);
char toupper(char const);
void qu_append_c_name_upper(struct obstack *ob, const char *name) {
  if (isdigit(*name))
    obstack_1grow(ob, '_');
  while (*name) {
    if (isalnum(*name)) {
      obstack_1grow(ob, toupper(*name));
    } else {
      obstack_1grow(ob, '_');
    }
    ++name;
  }
}


x86 assembly (clang, -O0):
<qu_append_c_name_upper>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     1174 <qu_append_c_name_upper+0x34>
mov    -0x8(%rbp),%rdi
mov    $0x5f,%esi
call   1060 <obstack_1grow@plt>
jmp    1179 <qu_append_c_name_upper+0x39>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     11e0 <qu_append_c_name_upper+0xa0>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1050 <isalnum@plt>
cmp    $0x0,%rax
je     11c1 <qu_append_c_name_upper+0x81>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <toupper@plt>
mov    -0x18(%rbp),%rdi
movsbl %al,%esi
call   1060 <obstack_1grow@plt>
jmp    11cf <qu_append_c_name_upper+0x8f>
mov    -0x8(%rbp),%rdi
mov    $0x5f,%esi
call   1060 <obstack_1grow@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1179 <qu_append_c_name_upper+0x39>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<qu_append_c_name_upper>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
movsbl (%rsi),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     1164 <qu_append_c_name_upper+0x24>
mov    %r14,%rdi
mov    $0x5f,%esi
call   1060 <obstack_1grow@plt>
mov    (%rbx),%al
test   %al,%al
je     11a0 <qu_append_c_name_upper+0x60>
add    $0x1,%rbx
jmp    118f <qu_append_c_name_upper+0x4f>
movsbl -0x1(%rbx),%edi
call   1040 <toupper@plt>
movsbl %al,%esi
mov    %r14,%rdi
call   1060 <obstack_1grow@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     11a0 <qu_append_c_name_upper+0x60>
movsbl %al,%edi
call   1050 <isalnum@plt>
test   %rax,%rax
jne    1170 <qu_append_c_name_upper+0x30>
mov    $0x5f,%al
jmp    1179 <qu_append_c_name_upper+0x39>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.obstack = type { i32 }
define void @qu_append_c_name_upper(%struct.obstack* %0, i8* %1) {
%3 = alloca %struct.obstack*
%4 = alloca i8*
store %struct.obstack* %0, %struct.obstack** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %4
%6 = load i8, i8* %5
%7 = call i64 @isdigit(i8 signext %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load %struct.obstack*, %struct.obstack** %3
%11 = call i32 @obstack_1grow(%struct.obstack* %10, i8 signext 95)
br label %12
12: ; preds = %9, %2
br label %13
13: ; preds = %31, %12
%14 = load i8*, i8** %4
%15 = load i8, i8* %14
%16 = icmp ne i8 %15, 0
br i1 %16, label %17, label %34
17: ; preds = %13
%18 = load i8*, i8** %4
%19 = load i8, i8* %18
%20 = call i64 @isalnum(i8 signext %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %28
22: ; preds = %17
%23 = load %struct.obstack*, %struct.obstack** %3
%24 = load i8*, i8** %4
%25 = load i8, i8* %24
%26 = call signext i8 @toupper(i8 signext %25)
%27 = call i32 @obstack_1grow(%struct.obstack* %23, i8 signext %26)
br label %31
28: ; preds = %17
%29 = load %struct.obstack*, %struct.obstack** %3
%30 = call i32 @obstack_1grow(%struct.obstack* %29, i8 signext 95)
br label %31
31: ; preds = %28, %22
%32 = load i8*, i8** %4
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %4
br label %13
34: ; preds = %13
ret void
}

LLVM IR (-O2):
%struct.obstack = type { i32 }
define void @qu_append_c_name_upper(%struct.obstack* %0, i8* nocapture %1) {
%3 = load i8, i8* %1
%4 = tail call i64 @isdigit(i8 signext %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = tail call i32 @obstack_1grow(%struct.obstack* %0, i8 signext 95)
br label %8
8: ; preds = %6, %2
%9 = load i8, i8* %1
%10 = icmp eq i8 %9, 0
br i1 %10, label %25, label %11
11: ; preds = %8, %19
%12 = phi i8 [ %23, %19 ], [ %9, %8 ]
%13 = phi i8* [ %22, %19 ], [ %1, %8 ]
%14 = tail call i64 @isalnum(i8 signext %12)
%15 = icmp eq i64 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %11
%17 = load i8, i8* %13
%18 = tail call signext i8 @toupper(i8 signext %17)
br label %19
19: ; preds = %11, %16
%20 = phi i8 [ %18, %16 ], [ 95, %11 ]
%21 = tail call i32 @obstack_1grow(%struct.obstack* %0, i8 signext %20)
%22 = getelementptr inbounds i8, i8* %13, i64 1
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 0
br i1 %24, label %25, label %11
25: ; preds = %19, %8
ret void
}