#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 */
struct utmpx {
  int /*<<< orphan*/ ut_id;
  int /*<<< orphan*/ ut_tv;
  int /*<<< orphan*/ ut_type;
};

/* Variables and functions */
int /*<<< orphan*/ DEAD_PROCESS;
scalar_t__ b16_pton(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ gettimeofday(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ *pututxline(struct utmpx *);
int /*<<< orphan*/ stderr;
size_t strlen(char *);
int /*<<< orphan*/ strncpy(int /*<<< orphan*/, char *, int);
int rm(char *id[]) {
  struct utmpx utx = {.ut_type = DEAD_PROCESS};
  size_t len;
  int ret = 0;
  (void)gettimeofday(&utx.ut_tv, NULL);
  for (; *id != NULL; id++) {
    len = strlen(*id);
    if (len <= sizeof(utx.ut_id)) {
      strncpy(utx.ut_id, *id, sizeof(utx.ut_id));
    } else if (len != sizeof(utx.ut_id) * 2 ||
               b16_pton(*id, utx.ut_id, sizeof(utx.ut_id)) != 0) {
      fprintf(stderr, "%s: Invalid identifier format\n", *id);
      ret = 1;
      continue;
    }
    if (pututxline(&utx) == NULL) {
      perror(*id);
      ret = 1;
    }
  }
  return (ret);
}


x86 assembly (clang, -O0):
<rm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    0x2e47(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
lea    -0x18(%rbp),%rdi
add    $0x4,%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
je     1282 <rm+0x112>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x4,-0x20(%rbp)
ja     11f0 <rm+0x80>
mov    -0x18(%rbp),%edi
mov    -0x8(%rbp),%rax
mov    (%rax),%rsi
mov    $0x4,%edx
call   1030 <strncpy@plt>
jmp    1246 <rm+0xd6>
cmpq   $0x8,-0x20(%rbp)
jne    1219 <rm+0xa9>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%esi
mov    $0x4,%edx
call   1090 <b16_pton@plt>
cmp    $0x0,%rax
je     1241 <rm+0xd1>
mov    0x2dc0(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
mov    (%rax),%rdx
lea    0xdd0(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x24(%rbp)
jmp    1271 <rm+0x101>
jmp    1246 <rm+0xd6>
lea    -0x18(%rbp),%rdi
call   1060 <pututxline@plt>
cmp    $0x0,%rax
jne    126c <rm+0xfc>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1080 <perror@plt>
movl   $0x1,-0x24(%rbp)
jmp    1271 <rm+0x101>
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
jmp    11ae <rm+0x3e>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rm>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r13
movq   $0x0,0x8(%rsp)
lea    0xc(%rsp),%rdi
mov    0x2e42(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
xor    %r12d,%r12d
xor    %esi,%esi
call   1050 <gettimeofday@plt>
mov    0x0(%r13),%rbx
test   %rbx,%rbx
je     1252 <rm+0xe2>
xor    %r12d,%r12d
lea    0x8(%rsp),%r14
mov    0x2e1e(%rip),%rbp
lea    0xe37(%rip),%r15
jmp    11f0 <rm+0x80>
mov    0x0(%r13),%rbx
mov    0x0(%rbp),%edi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1070 <fprintf@plt>
mov    $0x1,%r12d
mov    0x8(%r13),%rbx
add    $0x8,%r13
test   %rbx,%rbx
je     1252 <rm+0xe2>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    $0x4,%rax
ja     1230 <rm+0xc0>
mov    0x8(%rsp),%edi
mov    %rbx,%rsi
mov    $0x4,%edx
call   1030 <strncpy@plt>
mov    %r14,%rdi
call   1060 <pututxline@plt>
test   %rax,%rax
jne    11e3 <rm+0x73>
mov    0x0(%r13),%rdi
call   1080 <perror@plt>
jmp    11dd <rm+0x6d>
nopw   0x0(%rax,%rax,1)
cmp    $0x8,%rax
jne    11cf <rm+0x5f>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1090 <b16_pton@plt>
test   %rax,%rax
jne    11cb <rm+0x5b>
jmp    120f <rm+0x9f>
mov    %r12d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.utmpx = type { i32, i32, i32 }
@DEAD_PROCESS = global i32 0
@stderr = global i32 0
@.str = [31 x i8] c"%s: Invalid identifier format\0A\00"
define i32 @rm(i8** %0) {
%2 = alloca i8**
%3 = alloca %struct.utmpx
%4 = alloca i64
%5 = alloca i32
store i8** %0, i8*** %2
%6 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %3, i32 0, i32 0
store i32 0, i32* %6
%7 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %3, i32 0, i32 1
store i32 0, i32* %7
%8 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %3, i32 0, i32 2
%9 = load i32, i32* @DEAD_PROCESS
store i32 %9, i32* %8
store i32 0, i32* %5
%10 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %3, i32 0, i32 1
%11 = call i32 @gettimeofday(i32* %10, i32* null)
br label %12
12: ; preds = %52, %1
%13 = load i8**, i8*** %2
%14 = load i8*, i8** %13
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %55
16: ; preds = %12
%17 = load i8**, i8*** %2
%18 = load i8*, i8** %17
%19 = call i64 @strlen(i8* %18)
store i64 %19, i64* %4
%20 = load i64, i64* %4
%21 = icmp ule i64 %20, 4
br i1 %21, label %22, label %28
22: ; preds = %16
%23 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %3, i32 0, i32 0
%24 = load i32, i32* %23
%25 = load i8**, i8*** %2
%26 = load i8*, i8** %25
%27 = call i32 @strncpy(i32 %24, i8* %26, i32 4)
br label %44
28: ; preds = %16
%29 = load i64, i64* %4
%30 = icmp ne i64 %29, 8
br i1 %30, label %38, label %31
31: ; preds = %28
%32 = load i8**, i8*** %2
%33 = load i8*, i8** %32
%34 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %3, i32 0, i32 0
%35 = load i32, i32* %34
%36 = call i64 @b16_pton(i8* %33, i32 %35, i32 4)
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %43
38: ; preds = %31, %28
%39 = load i32, i32* @stderr
%40 = load i8**, i8*** %2
%41 = load i8*, i8** %40
%42 = call i32 @fprintf(i32 %39, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %41)
store i32 1, i32* %5
br label %52
43: ; preds = %31
br label %44
44: ; preds = %43, %22
%45 = call i32* @pututxline(%struct.utmpx* %3)
%46 = icmp eq i32* %45, null
br i1 %46, label %47, label %51
47: ; preds = %44
%48 = load i8**, i8*** %2
%49 = load i8*, i8** %48
%50 = call i32 @perror(i8* %49)
store i32 1, i32* %5
br label %51
51: ; preds = %47, %44
br label %52
52: ; preds = %51, %38
%53 = load i8**, i8*** %2
%54 = getelementptr inbounds i8*, i8** %53, i32 1
store i8** %54, i8*** %2
br label %12
55: ; preds = %12
%56 = load i32, i32* %5
ret i32 %56
}

LLVM IR (-O2):
%struct.utmpx = type { i32, i32, i32 }
@DEAD_PROCESS = global i32 0
@stderr = global i32 0
@.str = [31 x i8] c"%s: Invalid identifier format\0A\00"
define i32 @rm(i8** nocapture %0) {
%2 = alloca %struct.utmpx
%3 = bitcast %struct.utmpx* %2 to i8*
%4 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %2, i64 0, i32 0
store i32 0, i32* %4
%5 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %2, i64 0, i32 1
store i32 0, i32* %5
%6 = getelementptr inbounds %struct.utmpx, %struct.utmpx* %2, i64 0, i32 2
%7 = load i32, i32* @DEAD_PROCESS
store i32 %7, i32* %6
%8 = call i32 @gettimeofday(i32* %5, i32* null)
%9 = load i8*, i8** %0
%10 = icmp eq i8* %9, null
br i1 %10, label %43, label %11
11: ; preds = %1, %38
%12 = phi i8* [ %41, %38 ], [ %9, %1 ]
%13 = phi i32 [ %39, %38 ], [ 0, %1 ]
%14 = phi i8** [ %40, %38 ], [ %0, %1 ]
%15 = call i64 @strlen(i8* %12)
%16 = icmp ult i64 %15, 5
br i1 %16, label %17, label %20
17: ; preds = %11
%18 = load i32, i32* %4
%19 = call i32 @strncpy(i32 %18, i8* %12, i32 4)
br label %32
20: ; preds = %11
%21 = icmp eq i64 %15, 8
br i1 %21, label %22, label %28
22: ; preds = %20
%23 = load i32, i32* %4
%24 = call i64 @b16_pton(i8* %12, i32 %23, i32 4)
%25 = icmp eq i64 %24, 0
br i1 %25, label %32, label %26
26: ; preds = %22
%27 = load i8*, i8** %14
br label %28
28: ; preds = %26, %20
%29 = phi i8* [ %27, %26 ], [ %12, %20 ]
%30 = load i32, i32* @stderr
%31 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %29)
br label %38
32: ; preds = %22, %17
%33 = call i32* @pututxline(%struct.utmpx* %2)
%34 = icmp eq i32* %33, null
br i1 %34, label %35, label %38
35: ; preds = %32
%36 = load i8*, i8** %14
%37 = call i32 @perror(i8* %36)
br label %38
38: ; preds = %32, %35, %28
%39 = phi i32 [ 1, %35 ], [ %13, %32 ], [ 1, %28 ]
%40 = getelementptr inbounds i8*, i8** %14, i64 1
%41 = load i8*, i8** %40
%42 = icmp eq i8* %41, null
br i1 %42, label %43, label %11
43: ; preds = %38, %1
%44 = phi i32 [ 0, %1 ], [ %39, %38 ]
ret i32 %44
}