#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 can_ctrlmode {
  int /*<<< orphan*/ mask;
  int /*<<< orphan*/ flags;
};
typedef int /*<<< orphan*/ __u32;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
void set_ctrlmode(char *name, char *arg, struct can_ctrlmode *cm, __u32 flags) {
  if (strcmp(arg, "on") == 0) {
    cm->flags |= flags;
  } else if (strcmp(arg, "off") != 0) {
    fprintf(stderr,
            "Error: argument of \"%s\" must be \"on\" or \"off\", not \"%s\"\n",
            name, arg);
    exit(-1);
  }
  cm->mask |= flags;
}


x86 assembly (clang, -O0):
<set_ctrlmode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeae(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1173 <set_ctrlmode+0x43>
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%rax
or     0x4(%rax),%ecx
mov    %ecx,0x4(%rax)
jmp    11b9 <set_ctrlmode+0x89>
mov    -0x10(%rbp),%rdi
lea    0xe85(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     11b4 <set_ctrlmode+0x84>
mov    0x2e4c(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe62(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
jmp    11b9 <set_ctrlmode+0x89>
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%rax
or     (%rax),%ecx
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_ctrlmode>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r15d
mov    %rdx,%rbp
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xeb6(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1190 <set_ctrlmode+0x60>
lea    0xea5(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1194 <set_ctrlmode+0x64>
mov    0x2e6e(%rip),%rax
mov    (%rax),%edi
lea    0xe8c(%rip),%rsi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
or     %r15d,0x4(%rbp)
or     %r15d,0x0(%rbp)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.can_ctrlmode = type { i32, i32 }
@.str = [3 x i8] c"on\00"
@.str.1 = [4 x i8] c"off\00"
@stderr = global i32 0
@.str.2 = [57 x i8] c"Error: argument of \22%s\22 must be \22on\22 or \22off\22, not \22%s\22\0A\00"
define void @set_ctrlmode(i8* %0, i8* %1, %struct.can_ctrlmode* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca %struct.can_ctrlmode*
%8 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store %struct.can_ctrlmode* %2, %struct.can_ctrlmode** %7
store i32 %3, i32* %8
%9 = load i8*, i8** %6
%10 = call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %18
12: ; preds = %4
%13 = load i32, i32* %8
%14 = load %struct.can_ctrlmode*, %struct.can_ctrlmode** %7
%15 = getelementptr inbounds %struct.can_ctrlmode, %struct.can_ctrlmode* %14, i32 0, i32 1
%16 = load i32, i32* %15
%17 = or i32 %16, %13
store i32 %17, i32* %15
br label %29
18: ; preds = %4
%19 = load i8*, i8** %6
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %28
22: ; preds = %18
%23 = load i32, i32* @stderr
%24 = load i8*, i8** %5
%25 = load i8*, i8** %6
%26 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0), i8* %24, i8* %25)
%27 = call i32 @exit(i32 -1)
unreachable
28: ; preds = %18
br label %29
29: ; preds = %28, %12
%30 = load i32, i32* %8
%31 = load %struct.can_ctrlmode*, %struct.can_ctrlmode** %7
%32 = getelementptr inbounds %struct.can_ctrlmode, %struct.can_ctrlmode* %31, i32 0, i32 0
%33 = load i32, i32* %32
%34 = or i32 %33, %30
store i32 %34, i32* %32
ret void
}

LLVM IR (-O2):
%struct.can_ctrlmode = type { i32, i32 }
@.str = [3 x i8] c"on\00"
@.str.1 = [4 x i8] c"off\00"
@stderr = global i32 0
@.str.2 = [57 x i8] c"Error: argument of \22%s\22 must be \22on\22 or \22off\22, not \22%s\22\0A\00"
define void @set_ctrlmode(i8* %0, i8* %1, %struct.can_ctrlmode* nocapture %2, i32 %3) {
%5 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %4
%8 = getelementptr inbounds %struct.can_ctrlmode, %struct.can_ctrlmode* %2, i64 0, i32 1
%9 = load i32, i32* %8
%10 = or i32 %9, %3
store i32 %10, i32* %8
br label %18
11: ; preds = %4
%12 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %11
%15 = load i32, i32* @stderr
%16 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0), i8* %0, i8* %1)
%17 = tail call i32 @exit(i32 -1)
unreachable
18: ; preds = %11, %7
%19 = getelementptr inbounds %struct.can_ctrlmode, %struct.can_ctrlmode* %2, i64 0, i32 0
%20 = load i32, i32* %19
%21 = or i32 %20, %3
store i32 %21, i32* %19
ret void
}