#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 GetDriveType(char *);
int /*<<< orphan*/ strcpy(char *, char *);
unsigned long query_drivemap(void) {
  unsigned long map = 0L;
  int d, type;
  char buf[4];
  strcpy(buf, "A:\\");
  for (d = 0; d <= 'Z' - 'A'; d++) {
    buf[0] = 'A' + d;
    type = GetDriveType(buf);
    if (type != 0 && type != 1)
      map |= (1L << d);
  }
  return map;
}


x86 assembly (clang, -O0):
<query_drivemap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movq   $0x0,-0x8(%rbp)
lea    -0x14(%rbp),%rdi
lea    0xec5(%rip),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x19,-0xc(%rbp)
jg     11a2 <query_drivemap+0x82>
mov    -0xc(%rbp),%eax
add    $0x41,%eax
mov    %al,-0x14(%rbp)
lea    -0x14(%rbp),%rdi
call   1040 <GetDriveType@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     118f <query_drivemap+0x6f>
cmpl   $0x1,-0x10(%rbp)
je     118f <query_drivemap+0x6f>
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
mov    $0x1,%eax
shl    %cl,%rax
or     -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1194 <query_drivemap+0x74>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1147 <query_drivemap+0x27>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<query_drivemap>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xed0(%rip),%rsi
lea    0xc(%rsp),%r14
mov    %r14,%rdi
call   1030 <strcpy@plt>
xor    %ebx,%ebx
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0x41(%rbx),%eax
mov    %al,0xc(%rsp)
mov    %r14,%rdi
call   1040 <GetDriveType@plt>
mov    $0x1,%edx
mov    %ebx,%ecx
shl    %cl,%rdx
cmp    $0x2,%eax
mov    $0x0,%eax
cmovae %rdx,%rax
or     %rax,%r15
add    $0x1,%rbx
cmp    $0x1a,%rbx
jne    1150 <query_drivemap+0x30>
mov    %r15,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"A:\\\00"
define i64 @query_drivemap() {
%1 = alloca i64
%2 = alloca i32
%3 = alloca i32
%4 = alloca [4 x i8]
store i64 0, i64* %1
%5 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%6 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %7
7: ; preds = %29, %0
%8 = load i32, i32* %2
%9 = icmp sle i32 %8, 25
br i1 %9, label %10, label %32
10: ; preds = %7
%11 = load i32, i32* %2
%12 = add nsw i32 65, %11
%13 = trunc i32 %12 to i8
%14 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
store i8 %13, i8* %14
%15 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%16 = call i32 @GetDriveType(i8* %15)
store i32 %16, i32* %3
%17 = load i32, i32* %3
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %28
19: ; preds = %10
%20 = load i32, i32* %3
%21 = icmp ne i32 %20, 1
br i1 %21, label %22, label %28
22: ; preds = %19
%23 = load i32, i32* %2
%24 = zext i32 %23 to i64
%25 = shl i64 1, %24
%26 = load i64, i64* %1
%27 = or i64 %26, %25
store i64 %27, i64* %1
br label %28
28: ; preds = %22, %19, %10
br label %29
29: ; preds = %28
%30 = load i32, i32* %2
%31 = add nsw i32 %30, 1
store i32 %31, i32* %2
br label %7
32: ; preds = %7
%33 = load i64, i64* %1
ret i64 %33
}

LLVM IR (-O2):
@.str = [4 x i8] c"A:\\\00"
define i64 @query_drivemap() {
%1 = alloca [4 x i8]
%2 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 0
%3 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %0, %4
%5 = phi i64 [ 0, %0 ], [ %14, %4 ]
%6 = phi i64 [ 0, %0 ], [ %13, %4 ]
%7 = trunc i64 %5 to i8
%8 = add nuw nsw i8 %7, 65
store i8 %8, i8* %2
%9 = call i32 @GetDriveType(i8* %2)
%10 = icmp ult i32 %9, 2
%11 = shl nuw nsw i64 1, %5
%12 = select i1 %10, i64 0, i64 %11
%13 = or i64 %12, %6
%14 = add nuw nsw i64 %5, 1
%15 = icmp eq i64 %14, 26
br i1 %15, label %16, label %4
16: ; preds = %4
ret i64 %13
}