void remote_set_socket_file(const char *arg) {
  if (arg == ((void *)0))
    die("Socket argument missing");
  const char *p = arg;
  if (*p == '@')
    p++;
  while (isdigit((int)*p))
    p++;
  if (p == arg || *p != '\0')
    die("'%s': illegal display socket number", arg);
  if (p - arg > 4) {
    if (arg[0] != '@' || p - arg > 5)
      die("'%s': display socket number too large", arg);
  }
  fill_socket_file(arg);
}


x86 assembly (clang, -O0):
<remote_set_socket_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1155 <remote_set_socket_file+0x25>
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1050 <die@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x40,%eax
jne    1179 <remote_set_socket_file+0x49>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    117e <remote_set_socket_file+0x4e>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
je     11a4 <remote_set_socket_file+0x74>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    117e <remote_set_socket_file+0x4e>
mov    -0x10(%rbp),%rax
cmp    -0x8(%rbp),%rax
je     11c2 <remote_set_socket_file+0x92>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11d4 <remote_set_socket_file+0xa4>
mov    -0x8(%rbp),%rsi
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1050 <die@plt>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
cmp    $0x4,%rax
jle    1225 <remote_set_socket_file+0xf5>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x40,%eax
jne    120e <remote_set_socket_file+0xde>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
cmp    $0x5,%rax
jle    1220 <remote_set_socket_file+0xf0>
mov    -0x8(%rbp),%rsi
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1050 <die@plt>
jmp    1225 <remote_set_socket_file+0xf5>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1040 <fill_socket_file@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remote_set_socket_file>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
test   %rdi,%rdi
jne    113a <remote_set_socket_file+0x1a>
lea    0xecd(%rip),%rdi
xor    %eax,%eax
call   1040 <die@plt>
xor    %ebx,%ebx
cmpb   $0x40,(%r14)
sete   %bl
add    $0xffffffffffffffff,%rbx
nopw   0x0(%rax,%rax,1)
movsbl 0x1(%r14,%rbx,1),%eax
lea    -0x30(%rax),%ecx
add    $0x1,%rbx
cmp    $0xa,%ecx
jb     1150 <remote_set_socket_file+0x30>
test   %rbx,%rbx
je     116b <remote_set_socket_file+0x4b>
test   %al,%al
je     117c <remote_set_socket_file+0x5c>
lea    0xea6(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <die@plt>
cmp    $0x5,%rbx
jl     119b <remote_set_socket_file+0x7b>
jne    118a <remote_set_socket_file+0x6a>
cmpb   $0x40,(%r14)
je     119b <remote_set_socket_file+0x7b>
lea    0xeab(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <die@plt>
mov    %r14,%rdi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <fill_socket_file@plt>

LLVM IR (-O0):
@.str = [24 x i8] c"Socket argument missing\00"
@.str.1 = [36 x i8] c"'%s': illegal display socket number\00"
@.str.2 = [38 x i8] c"'%s': display socket number too large\00"
define void @remote_set_socket_file(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = call i32 (i8*, ...) bitcast (i32 (...)* @die to i32 (i8*, ...)*)(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %6, %1
%9 = load i8*, i8** %2
store i8* %9, i8** %3
%10 = load i8*, i8** %3
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 64
br i1 %13, label %14, label %17
14: ; preds = %8
%15 = load i8*, i8** %3
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %3
br label %17
17: ; preds = %14, %8
br label %18
18: ; preds = %24, %17
%19 = load i8*, i8** %3
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = call i32 @isdigit(i32 %21)
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %18
%25 = load i8*, i8** %3
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %3
br label %18
27: ; preds = %18
%28 = load i8*, i8** %3
%29 = load i8*, i8** %2
%30 = icmp eq i8* %28, %29
br i1 %30, label %36, label %31
31: ; preds = %27
%32 = load i8*, i8** %3
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %31, %27
%37 = load i8*, i8** %2
%38 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @die to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* %37)
br label %39
39: ; preds = %36, %31
%40 = load i8*, i8** %3
%41 = load i8*, i8** %2
%42 = ptrtoint i8* %40 to i64
%43 = ptrtoint i8* %41 to i64
%44 = sub i64 %42, %43
%45 = icmp sgt i64 %44, 4
br i1 %45, label %46, label %63
46: ; preds = %39
%47 = load i8*, i8** %2
%48 = getelementptr inbounds i8, i8* %47, i64 0
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = icmp ne i32 %50, 64
br i1 %51, label %59, label %52
52: ; preds = %46
%53 = load i8*, i8** %3
%54 = load i8*, i8** %2
%55 = ptrtoint i8* %53 to i64
%56 = ptrtoint i8* %54 to i64
%57 = sub i64 %55, %56
%58 = icmp sgt i64 %57, 5
br i1 %58, label %59, label %62
59: ; preds = %52, %46
%60 = load i8*, i8** %2
%61 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @die to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* %60)
br label %62
62: ; preds = %59, %52
br label %63
63: ; preds = %62, %39
%64 = load i8*, i8** %2
%65 = call i32 (i8*, ...) bitcast (i32 (...)* @fill_socket_file to i32 (i8*, ...)*)(i8* %64)
ret void
}

LLVM IR (-O2):
@.str = [24 x i8] c"Socket argument missing\00"
@.str.1 = [36 x i8] c"'%s': illegal display socket number\00"
@.str.2 = [38 x i8] c"'%s': display socket number too large\00"
define void @remote_set_socket_file(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 (i8*, ...) bitcast (i32 (...)* @die to i32 (i8*, ...)*)(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %3, %1
%6 = load i8, i8* %0
%7 = icmp eq i8 %6, 64
%8 = zext i1 %7 to i64
%9 = getelementptr i8, i8* %0, i64 %8
br label %10
10: ; preds = %10, %5
%11 = phi i8* [ %9, %5 ], [ %16, %10 ]
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = add nsw i32 %13, -48
%15 = icmp ult i32 %14, 10
%16 = getelementptr inbounds i8, i8* %11, i64 1
br i1 %15, label %10, label %17
17: ; preds = %10
%18 = icmp ne i8* %11, %0
%19 = icmp eq i8 %12, 0
%20 = select i1 %18, i1 %19, i1 false
br i1 %20, label %23, label %21
21: ; preds = %17
%22 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @die to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %23
23: ; preds = %17, %21
%24 = ptrtoint i8* %11 to i64
%25 = ptrtoint i8* %0 to i64
%26 = sub i64 %24, %25
%27 = icmp sgt i64 %26, 4
br i1 %27, label %28, label %35
28: ; preds = %23
%29 = load i8, i8* %0
%30 = icmp ne i8 %29, 64
%31 = icmp ne i64 %26, 5
%32 = or i1 %31, %30
br i1 %32, label %33, label %35
33: ; preds = %28
%34 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @die to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %35
35: ; preds = %28, %33, %23
%36 = tail call i32 (i8*, ...) bitcast (i32 (...)* @fill_socket_file to i32 (i8*, ...)*)(i8* %0)
ret void
}