#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__ strcmp(char *, char *);
int strlen(char *);
int check_pw(char *guess) {
  char pw[] = "rdbqds";
  int i;
  for (i = 0; i < strlen(pw); i++) {
    pw[i]++;
  }
  return (0 == strcmp(pw, guess));
}


x86 assembly (clang, -O0):
<check_pw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    0xece(%rip),%eax
mov    %eax,-0xf(%rbp)
mov    0xec8(%rip),%ax
mov    %ax,-0xb(%rbp)
mov    0xec0(%rip),%al
mov    %al,-0x9(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
lea    -0xf(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jge    1189 <check_pw+0x69>
movslq -0x14(%rbp),%rax
mov    -0xf(%rbp,%rax,1),%cl
add    $0x1,%cl
mov    %cl,-0xf(%rbp,%rax,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1150 <check_pw+0x30>
lea    -0xf(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_pw>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
movl   $0x736471,0xb(%rsp)
movl   $0x71626472,0x8(%rsp)
71
lea    0x8(%rsp),%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    1178 <check_pw+0x58>
xor    %ebx,%ebx
lea    0x8(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
addb   $0x1,0x8(%rsp,%rbx,1)
add    $0x1,%rbx
mov    %r15,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     1160 <check_pw+0x40>
lea    0x8(%rsp),%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
sete   %cl
mov    %ecx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.check_pw.pw = [7 x i8] c"rdbqds\00"
define i32 @check_pw(i8* %0) {
%2 = alloca i8*
%3 = alloca [7 x i8]
%4 = alloca i32
store i8* %0, i8** %2
%5 = bitcast [7 x i8]* %3 to i8*
store i32 0, i32* %4
br label %6
6: ; preds = %17, %1
%7 = load i32, i32* %4
%8 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 0
%9 = call i32 @strlen(i8* %8)
%10 = icmp slt i32 %7, %9
br i1 %10, label %11, label %20
11: ; preds = %6
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = add i8 %15, 1
store i8 %16, i8* %14
br label %17
17: ; preds = %11
%18 = load i32, i32* %4
%19 = add nsw i32 %18, 1
store i32 %19, i32* %4
br label %6
20: ; preds = %6
%21 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 0
%22 = load i8*, i8** %2
%23 = call i64 @strcmp(i8* %21, i8* %22)
%24 = icmp eq i64 0, %23
%25 = zext i1 %24 to i32
ret i32 %25
}

LLVM IR (-O2):
@__const.check_pw.pw = [7 x i8] c"rdbqds\00"
define i32 @check_pw(i8* %0) {
%2 = alloca [7 x i8]
%3 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%4 = call i32 @strlen(i8* %3)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %15
6: ; preds = %1, %6
%7 = phi i64 [ %11, %6 ], [ 0, %1 ]
%8 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 %7
%9 = load i8, i8* %8
%10 = add i8 %9, 1
store i8 %10, i8* %8
%11 = add nuw nsw i64 %7, 1
%12 = call i32 @strlen(i8* %3)
%13 = sext i32 %12 to i64
%14 = icmp slt i64 %11, %13
br i1 %14, label %6, label %15
15: ; preds = %6, %1
%16 = call i64 @strcmp(i8* %3, i8* %0)
%17 = icmp eq i64 %16, 0
%18 = zext i1 %17 to i32
ret i32 %18
}