#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;
  hardware = strdup(machine);
  if (!hardware) {
    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)
cmpq   $0x0,-0x10(%rbp)
jne    1195 <make_hardware+0x55>
mov    0x2e75(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x14(%rbp),%edi
mov    %rax,%rdx
lea    0xe75(%rip),%rsi
call   1040 <fprintf@plt>
jmp    11e6 <make_hardware+0xa6>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x4,%eax
jne    11e1 <make_hardware+0xa1>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x69,%eax
jne    11e1 <make_hardware+0xa1>
mov    -0x10(%rbp),%rax
movsbl 0x2(%rax),%eax
cmp    $0x38,%eax
jne    11e1 <make_hardware+0xa1>
mov    -0x10(%rbp),%rax
movsbl 0x3(%rax),%eax
cmp    $0x36,%eax
jne    11e1 <make_hardware+0xa1>
mov    -0x10(%rbp),%rax
movb   $0x33,0x1(%rax)
jmp    11e6 <make_hardware+0xa6>
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 = load i8*, i8** %3
%7 = icmp ne i8* %6, null
br i1 %7, label %13, label %8
8: ; preds = %1
%9 = load i32, i32* @stderr
%10 = load i32, i32* @errno
%11 = call i8* @strerror(i32 %10)
%12 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %11)
br label %39
13: ; preds = %1
%14 = load i8*, i8** %3
%15 = call i32 @strlen(i8* %14)
%16 = icmp eq i32 %15, 4
br i1 %16, label %17, label %38
17: ; preds = %13
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i64 0
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 105
br i1 %22, label %23, label %38
23: ; preds = %17
%24 = load i8*, i8** %3
%25 = getelementptr inbounds i8, i8* %24, i64 2
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 56
br i1 %28, label %29, label %38
29: ; preds = %23
%30 = load i8*, i8** %3
%31 = getelementptr inbounds i8, i8* %30, i64 3
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 54
br i1 %34, label %35, label %38
35: ; preds = %29
%36 = load i8*, i8** %3
%37 = getelementptr inbounds i8, i8* %36, i64 1
store i8 51, i8* %37
br label %38
38: ; preds = %35, %29, %23, %17, %13
br label %39
39: ; preds = %38, %8
%40 = load i8*, i8** %3
ret i8* %40
}

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
}