#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 blkpg_partition {
  int pno;
  scalar_t__ *volname;
  scalar_t__ *devname;
  scalar_t__ length;
  scalar_t__ start;
};
struct blkpg_ioctl_arg {
  int op;
  int datalen;
  struct blkpg_partition *data;
  scalar_t__ flags;
};
typedef int /*<<< orphan*/ p;

/* Variables and functions */
int /*<<< orphan*/ BLKPG;
int ioctl(int, int /*<<< orphan*/, struct blkpg_ioctl_arg *);
int partx_del_partition(int fd, int partno) {
  struct blkpg_ioctl_arg a;
  struct blkpg_partition p;
  p.pno = partno;
  p.start = 0;
  p.length = 0;
  p.devname[0] = 0;
  p.volname[0] = 0;
  a.op = 2;
  a.flags = 0;
  a.datalen = sizeof(p);
  a.data = &p;
  return ioctl(fd, BLKPG, &a);
}


x86 assembly (clang, -O0):
<partx_del_partition>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x48(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x38(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x40(%rbp),%rax
movq   $0x0,(%rax)
movl   $0x2,-0x20(%rbp)
movq   $0x0,-0x10(%rbp)
movl   $0x28,-0x1c(%rbp)
lea    -0x48(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e6e(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
call   1030 <ioctl@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
LLVM IR (-O0):
%struct.blkpg_ioctl_arg = type { i32, i32, %struct.blkpg_partition*, i64 }
%struct.blkpg_partition = type { i32, i64*, i64*, i64, i64 }
@BLKPG = global i32 0
define i32 @partx_del_partition(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.blkpg_ioctl_arg
%6 = alloca %struct.blkpg_partition
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = getelementptr inbounds %struct.blkpg_partition, %struct.blkpg_partition* %6, i32 0, i32 0
store i32 %7, i32* %8
%9 = getelementptr inbounds %struct.blkpg_partition, %struct.blkpg_partition* %6, i32 0, i32 4
store i64 0, i64* %9
%10 = getelementptr inbounds %struct.blkpg_partition, %struct.blkpg_partition* %6, i32 0, i32 3
store i64 0, i64* %10
%11 = getelementptr inbounds %struct.blkpg_partition, %struct.blkpg_partition* %6, i32 0, i32 2
%12 = load i64*, i64** %11
%13 = getelementptr inbounds i64, i64* %12, i64 0
store i64 0, i64* %13
%14 = getelementptr inbounds %struct.blkpg_partition, %struct.blkpg_partition* %6, i32 0, i32 1
%15 = load i64*, i64** %14
%16 = getelementptr inbounds i64, i64* %15, i64 0
store i64 0, i64* %16
%17 = getelementptr inbounds %struct.blkpg_ioctl_arg, %struct.blkpg_ioctl_arg* %5, i32 0, i32 0
store i32 2, i32* %17
%18 = getelementptr inbounds %struct.blkpg_ioctl_arg, %struct.blkpg_ioctl_arg* %5, i32 0, i32 3
store i64 0, i64* %18
%19 = getelementptr inbounds %struct.blkpg_ioctl_arg, %struct.blkpg_ioctl_arg* %5, i32 0, i32 1
store i32 40, i32* %19
%20 = getelementptr inbounds %struct.blkpg_ioctl_arg, %struct.blkpg_ioctl_arg* %5, i32 0, i32 2
store %struct.blkpg_partition* %6, %struct.blkpg_partition** %20
%21 = load i32, i32* %3
%22 = load i32, i32* @BLKPG
%23 = call i32 @ioctl(i32 %21, i32 %22, %struct.blkpg_ioctl_arg* %5)
ret i32 %23
}

LLVM IR (-O2):