#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__ is_alpha(char);
scalar_t__ is_number(char);
int good_direction(char *str) {
  char tmp;
  if (is_number(str[2]) == 0 && is_alpha(str[3]) == 0) {
    tmp = str[2];
    str[2] = str[3];
    str[3] = tmp;
  }
  if (is_number(str[5]) == 0 && is_alpha(str[6]) == 0) {
    tmp = str[5];
    str[5] = str[6];
    str[6] = tmp;
  }
  return (0);
}


x86 assembly (clang, -O0):
<good_direction>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl 0x2(%rax),%edi
call   1030 <is_number@plt>
cmp    $0x0,%rax
jne    117c <good_direction+0x5c>
mov    -0x8(%rbp),%rax
movsbl 0x3(%rax),%edi
call   1040 <is_alpha@plt>
cmp    $0x0,%rax
jne    117c <good_direction+0x5c>
mov    -0x8(%rbp),%rax
mov    0x2(%rax),%al
mov    %al,-0x9(%rbp)
mov    -0x8(%rbp),%rax
mov    0x3(%rax),%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x9(%rbp),%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x3(%rax)
mov    -0x8(%rbp),%rax
movsbl 0x5(%rax),%edi
call   1030 <is_number@plt>
cmp    $0x0,%rax
jne    11cc <good_direction+0xac>
mov    -0x8(%rbp),%rax
movsbl 0x6(%rax),%edi
call   1040 <is_alpha@plt>
cmp    $0x0,%rax
jne    11cc <good_direction+0xac>
mov    -0x8(%rbp),%rax
mov    0x5(%rax),%al
mov    %al,-0x9(%rbp)
mov    -0x8(%rbp),%rax
mov    0x6(%rax),%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x5(%rax)
mov    -0x9(%rbp),%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x6(%rax)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<good_direction>:
push   %rbx
mov    %rdi,%rbx
movsbl 0x2(%rdi),%edi
call   1030 <is_number@plt>
test   %rax,%rax
jne    1145 <good_direction+0x25>
movsbl 0x3(%rbx),%edi
call   1040 <is_alpha@plt>
test   %rax,%rax
jne    1145 <good_direction+0x25>
rolw   $0x8,0x2(%rbx)
movsbl 0x5(%rbx),%edi
call   1030 <is_number@plt>
test   %rax,%rax
jne    1166 <good_direction+0x46>
movsbl 0x6(%rbx),%edi
call   1040 <is_alpha@plt>
test   %rax,%rax
jne    1166 <good_direction+0x46>
rolw   $0x8,0x5(%rbx)
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @good_direction(i8* %0) {
%2 = alloca i8*
%3 = alloca i8
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = getelementptr inbounds i8, i8* %4, i64 2
%6 = load i8, i8* %5
%7 = call i64 @is_number(i8 signext %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %27
9: ; preds = %1
%10 = load i8*, i8** %2
%11 = getelementptr inbounds i8, i8* %10, i64 3
%12 = load i8, i8* %11
%13 = call i64 @is_alpha(i8 signext %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %27
15: ; preds = %9
%16 = load i8*, i8** %2
%17 = getelementptr inbounds i8, i8* %16, i64 2
%18 = load i8, i8* %17
store i8 %18, i8* %3
%19 = load i8*, i8** %2
%20 = getelementptr inbounds i8, i8* %19, i64 3
%21 = load i8, i8* %20
%22 = load i8*, i8** %2
%23 = getelementptr inbounds i8, i8* %22, i64 2
store i8 %21, i8* %23
%24 = load i8, i8* %3
%25 = load i8*, i8** %2
%26 = getelementptr inbounds i8, i8* %25, i64 3
store i8 %24, i8* %26
br label %27
27: ; preds = %15, %9, %1
%28 = load i8*, i8** %2
%29 = getelementptr inbounds i8, i8* %28, i64 5
%30 = load i8, i8* %29
%31 = call i64 @is_number(i8 signext %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %51
33: ; preds = %27
%34 = load i8*, i8** %2
%35 = getelementptr inbounds i8, i8* %34, i64 6
%36 = load i8, i8* %35
%37 = call i64 @is_alpha(i8 signext %36)
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %51
39: ; preds = %33
%40 = load i8*, i8** %2
%41 = getelementptr inbounds i8, i8* %40, i64 5
%42 = load i8, i8* %41
store i8 %42, i8* %3
%43 = load i8*, i8** %2
%44 = getelementptr inbounds i8, i8* %43, i64 6
%45 = load i8, i8* %44
%46 = load i8*, i8** %2
%47 = getelementptr inbounds i8, i8* %46, i64 5
store i8 %45, i8* %47
%48 = load i8, i8* %3
%49 = load i8*, i8** %2
%50 = getelementptr inbounds i8, i8* %49, i64 6
store i8 %48, i8* %50
br label %51
51: ; preds = %39, %33, %27
ret i32 0
}

LLVM IR (-O2):
define i32 @good_direction(i8* nocapture %0) {
%2 = getelementptr inbounds i8, i8* %0, i64 2
%3 = load i8, i8* %2
%4 = tail call i64 @is_number(i8 signext %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %14
6: ; preds = %1
%7 = getelementptr inbounds i8, i8* %0, i64 3
%8 = load i8, i8* %7
%9 = tail call i64 @is_alpha(i8 signext %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = load i8, i8* %2
%13 = load i8, i8* %7
store i8 %13, i8* %2
store i8 %12, i8* %7
br label %14
14: ; preds = %11, %6, %1
%15 = getelementptr inbounds i8, i8* %0, i64 5
%16 = load i8, i8* %15
%17 = tail call i64 @is_number(i8 signext %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %27
19: ; preds = %14
%20 = getelementptr inbounds i8, i8* %0, i64 6
%21 = load i8, i8* %20
%22 = tail call i64 @is_alpha(i8 signext %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %19
%25 = load i8, i8* %15
%26 = load i8, i8* %20
store i8 %26, i8* %15
store i8 %25, i8* %20
br label %27
27: ; preds = %24, %19, %14
ret i32 0
}