#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*/ errx(int, char *, char *);
int strtol(char *, char **, int);
int watchoids(int, int *);
int cmd_watch(int argc, char **argv) {
  int i;
  int oids[argc];
  char *end;
  for (i = 0; i < argc; i++) {
    oids[i] = strtol(argv[i], &end, 16);
    if (end != argv[i] + 4 || *end)
      errx(5, "4-digit hex number expected, got %s", argv[i]);
  }
  return watchoids(argc, oids);
}


x86 assembly (clang, -O0):
<cmd_watch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11fd <cmd_watch+0xcd>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x30(%rbp),%rsi
mov    $0x10,%edx
call   1050 <strtol@plt>
mov    %eax,%edx
mov    -0x38(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x30(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq -0x14(%rbp),%rdx
mov    (%rcx,%rdx,8),%rcx
add    $0x4,%rcx
cmp    %rcx,%rax
jne    11cd <cmd_watch+0x9d>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11ea <cmd_watch+0xba>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    $0x5,%edi
lea    0xe1b(%rip),%rsi
call   1040 <errx@plt>
jmp    11ef <cmd_watch+0xbf>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116d <cmd_watch+0x3d>
mov    -0x38(%rbp),%rsi
mov    -0x4(%rbp),%edi
call   1030 <watchoids@plt>
mov    -0x20(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_watch>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edi,%r14d
mov    %rsp,%r15
lea    0xf(,%r14,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    %edi,-0x2c(%rbp)
test   %edi,%edi
jle    11b7 <cmd_watch+0x87>
mov    %rsi,%rbx
xor    %r13d,%r13d
lea    -0x38(%rbp),%r12
jmp    118a <cmd_watch+0x5a>
nopl   0x0(%rax)
mov    $0x5,%edi
lea    0xe84(%rip),%rsi
call   1040 <errx@plt>
add    $0x1,%r13
cmp    %r13,%r14
je     11b7 <cmd_watch+0x87>
mov    (%rbx,%r13,8),%rdi
mov    %r12,%rsi
mov    $0x10,%edx
call   1050 <strtol@plt>
mov    %eax,(%r15,%r13,4)
mov    -0x38(%rbp),%rax
mov    (%rbx,%r13,8),%rdx
lea    0x4(%rdx),%rcx
cmp    %rcx,%rax
jne    1170 <cmd_watch+0x40>
cmpb   $0x0,(%rax)
jne    1170 <cmd_watch+0x40>
jmp    1181 <cmd_watch+0x51>
mov    -0x2c(%rbp),%edi
mov    %r15,%rsi
call   1030 <watchoids@plt>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [36 x i8] c"4-digit hex number expected, got %s\00"
define i32 @cmd_watch(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8*
store i32 %0, i32* %3
store i8** %1, i8*** %4
%9 = load i32, i32* %3
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %6
%12 = alloca i32, i64 %10
store i64 %10, i64* %7
store i32 0, i32* %5
br label %13
13: ; preds = %48, %2
%14 = load i32, i32* %5
%15 = load i32, i32* %3
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %51
17: ; preds = %13
%18 = load i8**, i8*** %4
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %18, i64 %20
%22 = load i8*, i8** %21
%23 = call i32 @strtol(i8* %22, i8** %8, i32 16)
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32, i32* %12, i64 %25
store i32 %23, i32* %26
%27 = load i8*, i8** %8
%28 = load i8**, i8*** %4
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8*, i8** %28, i64 %30
%32 = load i8*, i8** %31
%33 = getelementptr inbounds i8, i8* %32, i64 4
%34 = icmp ne i8* %27, %33
br i1 %34, label %40, label %35
35: ; preds = %17
%36 = load i8*, i8** %8
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %47
40: ; preds = %35, %17
%41 = load i8**, i8*** %4
%42 = load i32, i32* %5
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8*, i8** %41, i64 %43
%45 = load i8*, i8** %44
%46 = call i32 @errx(i32 5, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %45)
br label %47
47: ; preds = %40, %35
br label %48
48: ; preds = %47
%49 = load i32, i32* %5
%50 = add nsw i32 %49, 1
store i32 %50, i32* %5
br label %13
51: ; preds = %13
%52 = load i32, i32* %3
%53 = call i32 @watchoids(i32 %52, i32* %12)
%54 = load i8*, i8** %6
ret i32 %53
}

LLVM IR (-O2):
@.str = [36 x i8] c"4-digit hex number expected, got %s\00"
define i32 @cmd_watch(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = zext i32 %0 to i64
%5 = alloca i32, i64 %4
%6 = bitcast i8** %3 to i8*
%7 = icmp sgt i32 %0, 0
br i1 %7, label %8, label %26
8: ; preds = %2, %23
%9 = phi i64 [ %24, %23 ], [ 0, %2 ]
%10 = getelementptr inbounds i8*, i8** %1, i64 %9
%11 = load i8*, i8** %10
%12 = call i32 @strtol(i8* %11, i8** %3, i32 16)
%13 = getelementptr inbounds i32, i32* %5, i64 %9
store i32 %12, i32* %13
%14 = load i8*, i8** %3
%15 = load i8*, i8** %10
%16 = getelementptr inbounds i8, i8* %15, i64 4
%17 = icmp eq i8* %14, %16
br i1 %17, label %18, label %21
18: ; preds = %8
%19 = load i8, i8* %14
%20 = icmp eq i8 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %18, %8
%22 = tail call i32 @errx(i32 5, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %15)
br label %23
23: ; preds = %18, %21
%24 = add nuw nsw i64 %9, 1
%25 = icmp eq i64 %24, %4
br i1 %25, label %26, label %8
26: ; preds = %23, %2
%27 = call i32 @watchoids(i32 %0, i32* %5)
ret i32 %27
}