#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*/ exit(int);
int /*<<< orphan*/ htxcmd_display_usage(char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
char *htxcmd_get_sut_hostname(int argument_count, char *argument_vector[],
                              char *sut_hostname) {
  int i;
  char temp_error_string[256];
  for (i = 1; i < argument_count; i++) {
    if ((strncmp("-sut", argument_vector[i], strlen("-sut"))) == 0) {
      i++;
      if (i >= argument_count) {
        htxcmd_display_usage("Error : SUT hostname not provided with option");
        exit(1);
      }
      if (strlen(argument_vector[i]) > 256) {
        sprintf(temp_error_string,
                "Error : SUT hostname exceeded maximum length limit value <%d>",
                256);
        htxcmd_display_usage(temp_error_string);
        exit(1);
      }
      if (argument_vector[i][0] != '-') {
        strcpy(sut_hostname, argument_vector[i]);
        break;
      } else {
        htxcmd_display_usage("Error : Invalid SUT hostname");
        exit(1);
      }
    }
  }
  return sut_hostname;
}


x86 assembly (clang, -O0):
<htxcmd_get_sut_hostname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1297 <htxcmd_get_sut_hostname+0x137>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x128(%rbp)
lea    0xe5d(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x128(%rbp),%rsi
mov    %eax,%edx
lea    0xe48(%rip),%rdi
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1284 <htxcmd_get_sut_hostname+0x124>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jl     11f2 <htxcmd_get_sut_hostname+0x92>
lea    0xe22(%rip),%rdi
call   1060 <htxcmd_display_usage@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <strlen@plt>
cmp    $0x100,%eax
jle    123c <htxcmd_get_sut_hostname+0xdc>
lea    -0x120(%rbp),%rdi
lea    0xe17(%rip),%rsi
mov    $0x100,%edx
call   1070 <sprintf@plt>
lea    -0x120(%rbp),%rdi
call   1060 <htxcmd_display_usage@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     126e <htxcmd_get_sut_hostname+0x10e>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1040 <strcpy@plt>
jmp    1297 <htxcmd_get_sut_hostname+0x137>
lea    0xdfc(%rip),%rdi
call   1060 <htxcmd_display_usage@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    1289 <htxcmd_get_sut_hostname+0x129>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    117d <htxcmd_get_sut_hostname+0x1d>
mov    -0x18(%rbp),%rax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<htxcmd_get_sut_hostname>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    %rdx,0x8(%rsp)
cmp    $0x2,%edi
jl     11fb <htxcmd_get_sut_hostname+0x9b>
mov    %rsi,%r12
mov    %edi,%r15d
mov    %edi,%eax
mov    $0x1,%r14d
sub    %rax,%r14
mov    $0x2,%ebp
lea    0xe64(%rip),%r13
nopl   0x0(%rax)
mov    -0x8(%r12,%rbp,8),%rbx
mov    %r13,%rdi
call   1050 <strlen@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11d3 <htxcmd_get_sut_hostname+0x73>
lea    (%r14,%rbp,1),%rax
add    $0x1,%rax
add    $0x1,%rbp
cmp    $0x2,%rax
jne    11a0 <htxcmd_get_sut_hostname+0x40>
jmp    11fb <htxcmd_get_sut_hostname+0x9b>
cmp    %r15d,%ebp
jge    1212 <htxcmd_get_sut_hostname+0xb2>
mov    (%r12,%rbp,8),%rdi
call   1050 <strlen@plt>
cmp    $0x101,%eax
jge    121b <htxcmd_get_sut_hostname+0xbb>
mov    (%r12,%rbp,8),%rsi
cmpb   $0x2d,(%rsi)
je     1239 <htxcmd_get_sut_hostname+0xd9>
mov    0x8(%rsp),%rdi
call   1040 <strcpy@plt>
mov    0x8(%rsp),%rax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdec(%rip),%rdi
jmp    1240 <htxcmd_get_sut_hostname+0xe0>
lea    0xe11(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x100,%edx
call   1070 <sprintf@plt>
mov    %rbx,%rdi
jmp    1240 <htxcmd_get_sut_hostname+0xe0>
lea    0xe31(%rip),%rdi
call   1060 <htxcmd_display_usage@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"-sut\00"
@.str.1 = [46 x i8] c"Error : SUT hostname not provided with option\00"
@.str.2 = [62 x i8] c"Error : SUT hostname exceeded maximum length limit value <%d>\00"
@.str.3 = [29 x i8] c"Error : Invalid SUT hostname\00"
define i8* @htxcmd_get_sut_hostname(i32 %0, i8** %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca [256 x i8]
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* %2, i8** %6
store i32 1, i32* %7
br label %9
9: ; preds = %67, %3
%10 = load i32, i32* %7
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %70
13: ; preds = %9
%14 = load i8**, i8*** %5
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8*, i8** %14, i64 %16
%18 = load i8*, i8** %17
%19 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%20 = call i64 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %18, i32 %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %66
22: ; preds = %13
%23 = load i32, i32* %7
%24 = add nsw i32 %23, 1
store i32 %24, i32* %7
%25 = load i32, i32* %7
%26 = load i32, i32* %4
%27 = icmp sge i32 %25, %26
br i1 %27, label %28, label %31
28: ; preds = %22
%29 = call i32 @htxcmd_display_usage(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0))
%30 = call i32 @exit(i32 1)
unreachable
31: ; preds = %22
%32 = load i8**, i8*** %5
%33 = load i32, i32* %7
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8*, i8** %32, i64 %34
%36 = load i8*, i8** %35
%37 = call i32 @strlen(i8* %36)
%38 = icmp sgt i32 %37, 256
br i1 %38, label %39, label %45
39: ; preds = %31
%40 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%41 = call i32 @sprintf(i8* %40, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.2, i64 0, i64 0), i32 256)
%42 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%43 = call i32 @htxcmd_display_usage(i8* %42)
%44 = call i32 @exit(i32 1)
unreachable
45: ; preds = %31
%46 = load i8**, i8*** %5
%47 = load i32, i32* %7
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8*, i8** %46, i64 %48
%50 = load i8*, i8** %49
%51 = getelementptr inbounds i8, i8* %50, i64 0
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = icmp ne i32 %53, 45
br i1 %54, label %55, label %63
55: ; preds = %45
%56 = load i8*, i8** %6
%57 = load i8**, i8*** %5
%58 = load i32, i32* %7
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i8*, i8** %57, i64 %59
%61 = load i8*, i8** %60
%62 = call i32 @strcpy(i8* %56, i8* %61)
br label %70
63: ; preds = %45
%64 = call i32 @htxcmd_display_usage(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%65 = call i32 @exit(i32 1)
unreachable
66: ; preds = %13
br label %67
67: ; preds = %66
%68 = load i32, i32* %7
%69 = add nsw i32 %68, 1
store i32 %69, i32* %7
br label %9
70: ; preds = %55, %9
%71 = load i8*, i8** %6
ret i8* %71
}

LLVM IR (-O2):
@.str = [5 x i8] c"-sut\00"
@.str.1 = [46 x i8] c"Error : SUT hostname not provided with option\00"
@.str.2 = [62 x i8] c"Error : SUT hostname exceeded maximum length limit value <%d>\00"
@.str.3 = [29 x i8] c"Error : Invalid SUT hostname\00"
define i8* @htxcmd_get_sut_hostname(i32 %0, i8** nocapture %1, i8* returned %2) {
%4 = alloca [256 x i8]
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%6 = icmp sgt i32 %0, 1
br i1 %6, label %7, label %45
7: ; preds = %3
%8 = zext i32 %0 to i64
br label %9
9: ; preds = %7, %42
%10 = phi i64 [ 1, %7 ], [ %43, %42 ]
%11 = getelementptr inbounds i8*, i8** %1, i64 %10
%12 = load i8*, i8** %11
%13 = tail call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%14 = tail call i64 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %12, i32 %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %42
16: ; preds = %9
%17 = trunc i64 %10 to i32
%18 = add nuw nsw i32 %17, 1
%19 = icmp slt i32 %18, %0
br i1 %19, label %23, label %20
20: ; preds = %16
%21 = tail call i32 @htxcmd_display_usage(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0))
%22 = tail call i32 @exit(i32 1)
unreachable
23: ; preds = %16
%24 = zext i32 %18 to i64
%25 = getelementptr inbounds i8*, i8** %1, i64 %24
%26 = load i8*, i8** %25
%27 = tail call i32 @strlen(i8* %26)
%28 = icmp sgt i32 %27, 256
br i1 %28, label %29, label %33
29: ; preds = %23
%30 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @.str.2, i64 0, i64 0), i32 256)
%31 = call i32 @htxcmd_display_usage(i8* %5)
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %23
%34 = load i8*, i8** %25
%35 = load i8, i8* %34
%36 = icmp eq i8 %35, 45
br i1 %36, label %39, label %37
37: ; preds = %33
%38 = tail call i32 @strcpy(i8* %2, i8* %34)
br label %45
39: ; preds = %33
%40 = tail call i32 @htxcmd_display_usage(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%41 = tail call i32 @exit(i32 1)
unreachable
42: ; preds = %9
%43 = add nuw nsw i64 %10, 1
%44 = icmp eq i64 %43, %8
br i1 %44, label %45, label %9
45: ; preds = %42, %3, %37
ret i8* %2
}