#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*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
char *strdup(char const *);
char *strerror(int /*<<< orphan*/);
int strlen(char *);
char *make_hardware(const char *machine) {
  char *hardware;
  if (!(hardware = strdup(machine))) {
    fprintf(stderr, "strdup() failed: %s\n", strerror(errno));
    goto end;
  }
  if (strlen(hardware) == 4 && hardware[0] == 'i' && hardware[2] == '8' &&
      hardware[3] == '6') {
    hardware[1] = '3';
  }
end:
  return hardware;
}


x86 assembly (clang, -O0):
<make_hardware>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strdup@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    1194 <make_hardware+0x54>
mov    0x2e76(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    0x2e62(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x14(%rbp),%edi
mov    %rax,%rdx
lea    0xe76(%rip),%rsi
call   1040 <fprintf@plt>
jmp    11e5 <make_hardware+0xa5>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x4,%eax
jne    11e0 <make_hardware+0xa0>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x69,%eax
jne    11e0 <make_hardware+0xa0>
mov    -0x10(%rbp),%rax
movsbl 0x2(%rax),%eax
cmp    $0x38,%eax
jne    11e0 <make_hardware+0xa0>
mov    -0x10(%rbp),%rax
movsbl 0x3(%rax),%eax
cmp    $0x36,%eax
jne    11e0 <make_hardware+0xa0>
mov    -0x10(%rbp),%rax
movb   $0x33,0x1(%rax)
jmp    11e5 <make_hardware+0xa5>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_hardware>:
push   %rbp
push   %rbx
push   %rax
call   1050 <strdup@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1174 <make_hardware+0x34>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0x4,%eax
jne    119c <make_hardware+0x5c>
cmpb   $0x69,(%rbx)
jne    119c <make_hardware+0x5c>
cmpb   $0x38,0x2(%rbx)
jne    119c <make_hardware+0x5c>
cmpb   $0x36,0x3(%rbx)
jne    119c <make_hardware+0x5c>
movb   $0x33,0x1(%rbx)
jmp    119c <make_hardware+0x5c>
mov    0x2e65(%rip),%rax
mov    (%rax),%ebp
mov    0x2e54(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe6e(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
call   1040 <fprintf@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [21 x i8] c"strdup() failed: %s\0A\00"
@errno = global i32 0
define i8* @make_hardware(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i8* @strdup(i8* %4)
store i8* %5, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %12, label %7
7: ; preds = %1
%8 = load i32, i32* @stderr
%9 = load i32, i32* @errno
%10 = call i8* @strerror(i32 %9)
%11 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %38
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = call i32 @strlen(i8* %13)
%15 = icmp eq i32 %14, 4
br i1 %15, label %16, label %37
16: ; preds = %12
%17 = load i8*, i8** %3
%18 = getelementptr inbounds i8, i8* %17, i64 0
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 105
br i1 %21, label %22, label %37
22: ; preds = %16
%23 = load i8*, i8** %3
%24 = getelementptr inbounds i8, i8* %23, i64 2
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 56
br i1 %27, label %28, label %37
28: ; preds = %22
%29 = load i8*, i8** %3
%30 = getelementptr inbounds i8, i8* %29, i64 3
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 54
br i1 %33, label %34, label %37
34: ; preds = %28
%35 = load i8*, i8** %3
%36 = getelementptr inbounds i8, i8* %35, i64 1
store i8 51, i8* %36
br label %37
37: ; preds = %34, %28, %22, %16, %12
br label %38
38: ; preds = %37, %7
%39 = load i8*, i8** %3
ret i8* %39
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [21 x i8] c"strdup() failed: %s\0A\00"
@errno = global i32 0
define i8* @make_hardware(i8* nocapture %0) {
%2 = tail call i8* @strdup(i8* %0)
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %9
4: ; preds = %1
%5 = load i32, i32* @stderr
%6 = load i32, i32* @errno
%7 = tail call i8* @strerror(i32 %6)
%8 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %25
9: ; preds = %1
%10 = tail call i32 @strlen(i8* %2)
%11 = icmp eq i32 %10, 4
br i1 %11, label %12, label %25
12: ; preds = %9
%13 = load i8, i8* %2
%14 = icmp eq i8 %13, 105
br i1 %14, label %15, label %25
15: ; preds = %12
%16 = getelementptr inbounds i8, i8* %2, i64 2
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 56
br i1 %18, label %19, label %25
19: ; preds = %15
%20 = getelementptr inbounds i8, i8* %2, i64 3
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 54
br i1 %22, label %23, label %25
23: ; preds = %19
%24 = getelementptr inbounds i8, i8* %2, i64 1
store i8 51, i8* %24
br label %25
25: ; preds = %9, %12, %15, %19, %23, %4
ret i8* %2
}